added fifty move rule | bench 902872
This commit is contained in:
1 parent
8f96875145
commit
eb2cc35239
3 files changed
+23
-1
No files matched your search
@@ -9,6 +9,10 @@
|
||||
void Board::Reset() {
|
||||
castlingRights = 0;
|
||||
enPassantTarget = noEPTarget;
|
||||
|
||||
halfMoves = 0;
|
||||
fullMoves = 1;
|
||||
|
||||
sideToMove = White;
|
||||
occupied = 0ULL;
|
||||
|
||||
@@ -65,6 +69,12 @@ void Board::SetByFen(std::string_view fen) {
|
||||
|
||||
if (tokens[3] != "-") enPassantTarget = UTILS::parseSquare(tokens[3]);
|
||||
|
||||
// full and half move
|
||||
if (tokens.size() > 4) {
|
||||
halfMoves = std::stoi(tokens[4]);
|
||||
fullMoves = std::stoi(tokens[5]);
|
||||
}
|
||||
|
||||
occupied = colors[White] | colors[Black];
|
||||
hashKey = UTILS::GetHashKey(*this);
|
||||
MOVEGEN::GenThreatMaps(*this);
|
||||
@@ -340,6 +350,11 @@ bool Board::MakeMove(Move move) {
|
||||
if (InCheck()) return false;
|
||||
sideToMove = !sideToMove;
|
||||
|
||||
if (attackerColor == Black) fullMoves++;
|
||||
if (attackerPiece == Pawn || move.IsCapture()) {
|
||||
halfMoves = 0;
|
||||
}
|
||||
|
||||
positionIndex++;
|
||||
positionHistory[positionIndex] = hashKey;
|
||||
|
||||
|
||||
Reference in new issue
Block a user