Skip to content

Commit a8b6bf1

Browse files
mstemberaDisservin
authored andcommitted
Small Major/Minor piece key simplification/optimization.
closes #5710 No functional change
1 parent afaf3a0 commit a8b6bf1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/position.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void Position::set_state() const {
360360
{
361361
st->nonPawnMaterial[color_of(pc)] += PieceValue[pc];
362362

363-
if (type_of(pc) == QUEEN || type_of(pc) == ROOK)
363+
if (type_of(pc) >= ROOK)
364364
st->majorPieceKey ^= Zobrist::psq[pc][s];
365365

366366
else
@@ -759,7 +759,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
759759
st->nonPawnMaterial[them] -= PieceValue[captured];
760760
st->nonPawnKey[them] ^= Zobrist::psq[captured][capsq];
761761

762-
if (type_of(captured) == QUEEN || type_of(captured) == ROOK)
762+
if (type_of(captured) >= ROOK)
763763
st->majorPieceKey ^= Zobrist::psq[captured][capsq];
764764

765765
else
@@ -844,7 +844,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
844844
st->materialKey ^=
845845
Zobrist::psq[promotion][pieceCount[promotion] - 1] ^ Zobrist::psq[pc][pieceCount[pc]];
846846

847-
if (promotionType == QUEEN || promotionType == ROOK)
847+
if (promotionType >= ROOK)
848848
st->majorPieceKey ^= Zobrist::psq[promotion][to];
849849

850850
else
@@ -871,7 +871,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
871871
st->minorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
872872
}
873873

874-
else if (type_of(pc) == QUEEN || type_of(pc) == ROOK)
874+
else if (type_of(pc) >= ROOK)
875875
st->majorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
876876

877877
else

0 commit comments

Comments
 (0)