Hi, i want to complete my chess game including a human vs computer option. I would like to know if you can help me to find a known and very simple function that finds the best move. Thank you very much.
Hi, i want to complete my chess game including a human vs computer option. I would like to know if you can help me to find a known and very simple function that finds the best move. Thank you very much.
I would probably try to build this in stages.
my 1st stage would be to look for a winning move. i.e. one that causes check mate
2nd poss stage would be look for a capture of highest value for lowest cost.
have you had any thoughts yourself?
have you searched for some source code you could possibly learn from. Im sure i have seen source for chess games on the web.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Hi, it is very interesting to think about those stages. I have
thought when the computer decides the best move, then it must
change his color and decide the best move, and change the color..... a few times. In this way, it can evaluate the best move of a set of moves. But i don't know really if it works .
I am not very fond in chess, i am a newbie. I want this function
because i am a C/C++'s teacher and i want to propose a chess
game to my students, a complete one. I have found an interesting web. Take a look, there are a lot of program sources:
http://www.xs4all.nl/~verhelst/chess/sources.html
I will watch the sources in the next days.
See you,
Daniel.
To do a chess AI is not that hard.. unless you really want it to kick ass, since that will make you have to teach the computer some of the most common "chess strategies".
Basically as in all AI's, recursive methods is the way to go.
create a method that in general does this.
whatever FindBestMove("a move" //represented in anyway)
{
// Am I happy with the current situation, then in some way register this result and save the list of moves I've made so far.
return;
// Otherwise
//Find all possible moves I may do. Place these in some sort of list.
//Realise which one of them really suck, and throw those away.
//Run FindBestMove with each of the moves still left in the list.
}
When we are all done, we should have a lot of nice results registered .. analyse these to find out what is the best move..
Chess Mate
/Laos