Build a Mini-Chess State Evaluator

If you want to do better than random play, you will want to figure out what a good move is. We will say that a good move is one that produces a good state—this is a key idea for making things work.

Write a method for State that gives a value for that state. The value should be a floating point number between -1.0 and 1.0: positive numbers indicate an advantage for the side on move, and -1.0 (1.0) means a sure loss (win). This value is just a heuristic guess, so do not worry too much about whether it is perfect.

The easiest thing to do is to score as in standard chess: give each side 1 point for its Pawn, 3 for its Bishop or Knight, 5 for its Rook, and 9 for its Queen. Then subtract, and divide by 26 to normalize.

Once you have an scoring method, change your program to pick a random move that is worst for your opponent (and best for you). Make the program calculate the value of the state that your opponent gets for each move you could make in the current position and choose the worst one. (Remember that earlier we said that the value of a state is positive when the side on move has the advantage.)

Missed Opportunity: There are so many ways to make a better scoring function. Position would be useful. Also, the values should be tuned.


prev index next