I want to do a C program to find the minimum no. of moves needed to check mate in a king and rook Vs king,I am supposed to use mini max algorithm.A lot of search haven't led me to any thing fruitful.It would be of great help if some one give some steps how to do it.
2 Answers
Every min-max algorithm takes as granted you have the tree of all possible made positions. So for start you have to claculate this tree. King has limited moves (8) considering all the other pieces, hoewever the tree will grow big enough.
The function you shouldd use for evaluation is one that values up boards where opposite King tends to be placed towards the ending line of the board (because thats the mate positions if you know how mate is achieved in the scenario you are interested in). So in every position of the tree where king is closer to the end line of the board this function will have bigger value.
For my chess experience take in consideration that the max number of moves to mate in the scenario you are interested are 25 for every given board...
Simple example of function values for each position on the board:
100 90 90 90 90 90 90 100
90 80 80 80 80 80 80 90
90 80 70 70 70 70 80 90
90 80 70 60 60 70 80 90
90 80 70 60 60 70 80 90
90 80 70 70 70 70 80 90
90 80 80 80 80 80 80 90
100 90 90 90 90 90 90 100

- 14,282
- 9
- 46
- 72
-
1This doesn't exactly work. With just this evaluation the engine isn't guaranteed to find an optimal mate. – Zong Jun 28 '13 at 05:47
I'd recommend defining all terminal positions (checkmate and stalemate) and work backwards, creating a hash table of positions and "distance to mate" for each position. Or download a Nalimov tablebase, since this task has already been done!

- 855
- 10
- 21