Skip to content

Commit

Permalink
Small Major/Minor piece key simplification/optimization.
Browse files Browse the repository at this point in the history
closes #5710

No functional change
  • Loading branch information
mstembera authored and Disservin committed Dec 8, 2024
1 parent afaf3a0 commit a8b6bf1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void Position::set_state() const {
{
st->nonPawnMaterial[color_of(pc)] += PieceValue[pc];

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

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

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

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

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

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

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

else
Expand Down

0 comments on commit a8b6bf1

Please sign in to comment.