From 86f1df7134fa54fe93e90dc086d978e917256c2f Mon Sep 17 00:00:00 2001 From: anematode Date: Wed, 10 Jun 2026 23:01:50 +0200 Subject: [PATCH] Fix material key computation error Fixes an error introduced in 278a755fb552131b7e2a5da24256b6a4b13246fc https://github.com/official-stockfish/Stockfish/pull/6891 Also enables more checking in debug builds closes https://github.com/official-stockfish/Stockfish/pull/6894 No functional change --- src/position.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index c9ff87a53..2e35e78ac 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -989,8 +989,8 @@ void Position::do_move(Move m, // Update hash keys // Zobrist::psq[pc][to] is zero, so we don't need to clear it k ^= Zobrist::psq[promotion][to]; - st->materialKey ^= Zobrist::psq[promotion][8 + pieceCount[promotion] - 1] - ^ Zobrist::psq[pc][8 + pieceCount[pc]]; + st->materialKey ^= Zobrist::psq[promotion][8 + pieceCount[promotion]] + ^ Zobrist::psq[pc][8 + pieceCount[pc] - 1]; st->nonPawnKey[us] ^= Zobrist::psq[promotion][to]; if (pt <= BISHOP) @@ -1625,7 +1625,7 @@ bool Position::material_key_is_ok() const { return compute_material_key() == st- // This is meant to be helpful when debugging. bool Position::pos_is_ok() const { - constexpr bool Fast = true; // Quick (default) or full check? + constexpr bool Fast = false; // fast or full check? if ((sideToMove != WHITE && sideToMove != BLACK) || piece_on(square(WHITE)) != W_KING || piece_on(square(BLACK)) != B_KING