Skip to content

Commit

Permalink
Fix incremental update for hand pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfab committed Sep 4, 2021
1 parent 9dfae72 commit 802d492
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/nnue/features/half_ka_v2_variants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]];
Expand Down

0 comments on commit 802d492

Please sign in to comment.