Its a two player game, i am working on developing artificial intelligence based computer player.
American Chess rules are applied.
A 2D array is updated by the position of the chess pieces which are numbered (each piece corresponding to a number)
As the player selects a piece the corresponding number is checked for all possible places where it can move, then the program waits for the second place where it has to be moved.
After each turn the program calls the function "wholoses.m" which will see whether the king is there or not. I am working to change this logic as it should check for CHECK MATE also.
The main function to run is CHESS_on_MATLAB.m
that will call its fig itself
the main m file just calls function "playerturn.m" as the input is given by the user.
this function then calls different functions to check the position of the piece, win loss, etc
"checkfp.m" checks whether the position desired is possible or not, and gives the message if not possible.
Currently the winner has to kill the king while i realized that it should not be the case, it should detect the checkmate condition, so dont worry i am gonna update this in few coming days.
Suleman Shafqat (2021). Chess Master (https://www.mathworks.com/matlabcentral/fileexchange/30594-chess-master), MATLAB Central File Exchange. Retrieved .
Hi, i have a question!
how does it work the line in code that say "rc=h.r*10+h.c".
I don't understand of all, for example, if i want a move the blacknight in r=1 and c=2
then rc=13. This move the piece at side of blacknight and no that i want, and so
i really confused with this part. Can you help me?
Thanks for your code!! It was very useful since I could not understand well how to make the handling in the plays.
very nice work
first issue can be solved by writing
in opening function of the main function that is:
write "h.plrmark=1;" in line number "162" in "CHESS_on_MATLAB.m"
2nd Issue (En_passant) will be solved in next version of CHESS MASTER
thanks for ur feedback
* Black plays first!
* Clicking on the opposite side causes an error to throw in the console (MATLAB 2011b)
* En passsant is not implemented and is claimed as a wrong move.(http://en.wikipedia.org/wiki/En_passant).
@Newell: The aim is to understand how things work. You can reproduce code as per your OS's requirements.
The code included is commented for better understanding as well as future work for improvement, if you find any block elusive feel free to ask.
I'm eager to try this, but it's not compatible with a Unix-based system because it uses '\' for a file separator. It shouldn't take long to replace this by "filesep" wherever it occurs.
Thanks, gonna try it later. Looks interesting!
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!