From 6f607b47b406db5249af1eb24812e9a40ff2ebf3 Mon Sep 17 00:00:00 2001 From: Carlos Esparza Date: Mon, 27 Jan 2025 11:05:09 -0800 Subject: [PATCH] Fix materialKey no functional change bench: 1632964 --- src/position.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 7e0b5780426..b00e899f057 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -383,7 +383,7 @@ void Position::set_state() const { for (Piece pc : Pieces) for (int cnt = 0; cnt < pieceCount[pc]; ++cnt) - st->materialKey ^= Zobrist::psq[pc][cnt]; + st->materialKey ^= Zobrist::psq[pc][8 + cnt]; } @@ -783,7 +783,7 @@ void Position::do_move(Move m, remove_piece(capsq); k ^= Zobrist::psq[captured][capsq]; - st->materialKey ^= Zobrist::psq[captured][pieceCount[captured]]; + st->materialKey ^= Zobrist::psq[captured][8 + pieceCount[captured]]; // Reset rule 50 counter st->rule50 = 0; @@ -850,7 +850,7 @@ void Position::do_move(Move m, // Zobrist::psq[pc][to] is zero, so we don't need to clear it k ^= Zobrist::psq[promotion][to]; st->materialKey ^= - Zobrist::psq[promotion][pieceCount[promotion] - 1] ^ Zobrist::psq[pc][pieceCount[pc]]; + Zobrist::psq[promotion][8 + pieceCount[promotion] - 1] ^ Zobrist::psq[pc][8 + pieceCount[pc]]; if (promotionType <= BISHOP) st->minorPieceKey ^= Zobrist::psq[promotion][to];