Skip to content

Commit

Permalink
Fix materialKey
Browse files Browse the repository at this point in the history
no functional change
bench: 1632964
  • Loading branch information
ces42 committed Jan 27, 2025
1 parent 427392c commit 4848aa4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,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];
}


Expand Down Expand Up @@ -792,7 +792,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;
Expand Down Expand Up @@ -859,7 +859,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 >= ROOK)
st->majorPieceKey ^= Zobrist::psq[promotion][to];
Expand Down

0 comments on commit 4848aa4

Please sign in to comment.