|
|
The Move Applier The move applier is a long, but relatively straighforward piece of code. It takes a move, records it in the undo buffer, and applies it to the current board state. Each of the possible types of move are covered with a piece of code, i.e.
Pawn moves
- Reset the draw50 counter
- Check for en-passant, removing the enemy piece
- Check Pawn promotion
- Move the pawn
- If the pawn move is two squares, set up the en passant square for the next go
Castling Moves
- Check all squares involved in the castle are not attacked, as one can't castle through check
- Move both the king and the rook involved
- Update the appropriate king position data
King moves
Rook moves
- Clear the approprate castling flag
All moves The piece is moved in the board arrays to make the move
Left in check? We then check to see if the current player is in check, and if so we mark the move as invalid
Three move draw The three move draw test is based on that found in TCSP as described by John Stanback. It's a little difficult to describe, but I'll try and put up some more details here later.
If the move was invalid, we call the undo move function to reset the board state to how it was before the move. Finally, we return whether the move was invalid.
The Move Undo-er This is pretty much the same as the move applier, but in reverse.
|
|