Skip to content

Commit 4848aa4

Browse files
committed
Fix materialKey
no functional change bench: 1632964
1 parent 427392c commit 4848aa4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/position.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ void Position::set_state() const {
388388

389389
for (Piece pc : Pieces)
390390
for (int cnt = 0; cnt < pieceCount[pc]; ++cnt)
391-
st->materialKey ^= Zobrist::psq[pc][cnt];
391+
st->materialKey ^= Zobrist::psq[pc][8 + cnt];
392392
}
393393

394394

@@ -792,7 +792,7 @@ void Position::do_move(Move m,
792792
remove_piece(capsq);
793793

794794
k ^= Zobrist::psq[captured][capsq];
795-
st->materialKey ^= Zobrist::psq[captured][pieceCount[captured]];
795+
st->materialKey ^= Zobrist::psq[captured][8 + pieceCount[captured]];
796796

797797
// Reset rule 50 counter
798798
st->rule50 = 0;
@@ -859,7 +859,7 @@ void Position::do_move(Move m,
859859
// Zobrist::psq[pc][to] is zero, so we don't need to clear it
860860
k ^= Zobrist::psq[promotion][to];
861861
st->materialKey ^=
862-
Zobrist::psq[promotion][pieceCount[promotion] - 1] ^ Zobrist::psq[pc][pieceCount[pc]];
862+
Zobrist::psq[promotion][8 + pieceCount[promotion] - 1] ^ Zobrist::psq[pc][8 + pieceCount[pc]];
863863

864864
if (promotionType >= ROOK)
865865
st->majorPieceKey ^= Zobrist::psq[promotion][to];

0 commit comments

Comments
 (0)