From: Fabian Fichter Date: Sat, 4 Sep 2021 21:08:24 +0000 (+0200) Subject: Fix incremental update for hand pieces X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=802d4926f97216aebca8220ed3f7d58553e3afb5;p=fairystockfish.git Fix incremental update for hand pieces --- diff --git a/src/nnue/features/half_ka_v2_variants.cpp b/src/nnue/features/half_ka_v2_variants.cpp index 8e766f8..692ad52 100644 --- a/src/nnue/features/half_ka_v2_variants.cpp +++ b/src/nnue/features/half_ka_v2_variants.cpp @@ -85,7 +85,7 @@ namespace Stockfish::Eval::NNUE::Features { if (dp.from[i] != SQ_NONE) removed.push_back(make_index(perspective, dp.from[i], pc, oriented_ksq, pos)); else if (dp.handPiece[i] != NO_PIECE) - removed.push_back(make_index(perspective, dp.handCount[i], dp.handPiece[i], oriented_ksq, pos)); + removed.push_back(make_index(perspective, dp.handCount[i] - 1, dp.handPiece[i], oriented_ksq, pos)); if (dp.to[i] != SQ_NONE) added.push_back(make_index(perspective, dp.to[i], pc, oriented_ksq, pos)); else if (dp.handPiece[i] != NO_PIECE) diff --git a/src/position.cpp b/src/position.cpp index 8342845..f51e349 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1679,9 +1679,6 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { Square gate = gating_square(m); Piece gating_piece = make_piece(us, gating_type(m)); - put_piece(gating_piece, gate); - remove_from_hand(gating_piece); - if (Eval::useNNUE) { // Add gating piece @@ -1693,6 +1690,9 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { dp.dirty_num++; } + put_piece(gating_piece, gate); + remove_from_hand(gating_piece); + st->gatesBB[us] ^= gate; k ^= Zobrist::psq[gating_piece][gate]; st->materialKey ^= Zobrist::psq[gating_piece][pieceCount[gating_piece]];