Skip to content

Commit

Permalink
Remove pawnKey from StateInfo
Browse files Browse the repository at this point in the history
Remove pawnKey since it is not used anymore.

Passed Non-regression STC:
https://tests.stockfishchess.org/tests/view/64b023110cdec37b9573265c
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 334848 W: 85440 L: 85545 D: 163863
Ptnml(0-2): 1134, 38101, 89075, 37964, 1150

closes #4687

No functional change
  • Loading branch information
maxim authored and vondele committed Jul 16, 2023
1 parent e8a5c64 commit 18fdc2d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
12 changes: 1 addition & 11 deletions src/position.cpp
Expand Up @@ -336,7 +336,6 @@ void Position::set_check_info() const {
void Position::set_state() const {

st->key = st->materialKey = 0;
st->pawnKey = Zobrist::noPawns;
st->nonPawnMaterial[WHITE] = st->nonPawnMaterial[BLACK] = VALUE_ZERO;
st->checkersBB = attackers_to(square<KING>(sideToMove)) & pieces(~sideToMove);

Expand All @@ -348,10 +347,7 @@ void Position::set_state() const {
Piece pc = piece_on(s);
st->key ^= Zobrist::psq[pc][s];

if (type_of(pc) == PAWN)
st->pawnKey ^= Zobrist::psq[pc][s];

else if (type_of(pc) != KING)
if (type_of(pc) != KING && type_of(pc) != PAWN)
st->nonPawnMaterial[color_of(pc)] += PieceValue[MG][pc];
}

Expand Down Expand Up @@ -745,8 +741,6 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
assert(piece_on(to) == NO_PIECE);
assert(piece_on(capsq) == make_piece(them, PAWN));
}

st->pawnKey ^= Zobrist::psq[captured][capsq];
}
else
st->nonPawnMaterial[them] -= PieceValue[MG][captured];
Expand Down Expand Up @@ -825,17 +819,13 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {

// Update hash keys
k ^= Zobrist::psq[pc][to] ^ Zobrist::psq[promotion][to];
st->pawnKey ^= Zobrist::psq[pc][to];
st->materialKey ^= Zobrist::psq[promotion][pieceCount[promotion]-1]
^ Zobrist::psq[pc][pieceCount[pc]];

// Update material
st->nonPawnMaterial[us] += PieceValue[MG][promotion];
}

// Update pawn hash key
st->pawnKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];

// Reset rule 50 draw counter
st->rule50 = 0;
}
Expand Down
5 changes: 0 additions & 5 deletions src/position.h
Expand Up @@ -40,7 +40,6 @@ namespace Stockfish {
struct StateInfo {

// Copied when making a move
Key pawnKey;
Key materialKey;
Value nonPawnMaterial[COLOR_NB];
int castlingRights;
Expand Down Expand Up @@ -338,10 +337,6 @@ inline Key Position::adjust_key50(Key k) const
? k : k ^ make_key((st->rule50 - (14 - AfterMove)) / 8);
}

inline Key Position::pawn_key() const {
return st->pawnKey;
}

inline Key Position::material_key() const {
return st->materialKey;
}
Expand Down

0 comments on commit 18fdc2d

Please sign in to comment.