added the 50-move draw rule

This commit is contained in:
Karma Riuk 2025-02-06 22:39:11 +01:00
parent 6e567f2f11
commit d6aa977a15
2 changed files with 7 additions and 1 deletions

View File

@ -267,6 +267,12 @@ Board Board::make_move(Move move) const {
}
}
ret.n_half_moves = n_half_moves + 1;
if (is_capturing || piece_at(move.source_square) == Piece::Pawn)
ret.n_half_moves = 0;
if (!white_to_play)
ret.n_full_moves = n_full_moves + 1;
return ret;
}

View File

@ -43,7 +43,7 @@ struct Board {
}
bool is_terminal() const {
return insufficient_material() || white_to_play
return n_half_moves == 100 || insufficient_material() || white_to_play
? is_checkmate_for(White) || is_stalemate_for(White)
: is_checkmate_for(Black) || is_stalemate_for(Black);
}