Dec 25, 2006

[Plan] Draws, mate and stalemate

Before starting with the Alpha-Beta search I need to make things clear regarding to draws, mates and stalemates.

There are a number of ways a chess game can end and how they are handled by the engine:
  • Mate - A side has no legal moves while his king is in check.

    This is easily checked in the search. If we run into a position where a side has no legal moves, we check if its king is in check. If it is, the position is mate. This is awarded a very high value so the engine always tries to get it (or avoid it).

  • Stalemate - A side has no legal moves while his king is not in check.

    This will be the result if the check for mate does not find the king in check. It will be rewarded a zero value.

  • Lack of material draw - If neither side has enough material to mate.

    This will be handled by the position evaluation. Check the board for pieces, if not enough on the board (only at most knight or bishop on both sides). Awarded a zero value.

  • 50 moves draw - If 50 moves are made without a pawn move or a capture.

    Every board object holds a value for this as mentioned in earlier posts, so all we have to do is extract it at evaluation time. Awards a zero value.

  • Draw by repetition - If the same position arises three times with the same player at the move.

    This is one nasty thing to implement. Not only do we need to keep track of positions that already occured on the board, we also need to handle it in the search trees. I honestly have no idea where to start. Though it can be handled with the transposition table I am implementing later on. I will put off this until then.

So we got most cases covered. The three-fold repetition will just have to wait. Unfortunately I know by experience the engine can behave very annoying when it does not recognize that type of draw, but we will have to live with that for now.

No comments: