struct ReducedStateInfo {
Key key, pawnKey, materialKey;
int castleRights, rule50;
- Square epSquare;
+ Square kingSquare[2], epSquare;
Value mgValue, egValue;
Value npMaterial[2];
};
// If the moving piece was a king, update the king square
if (pt == KING)
- kingSquare[us] = to;
+ st->kingSquare[us] = to;
// Update piece lists, note that index[from] is not updated and
// becomes stale. This works as long as index[] is accessed just
// Update hash key
key ^= zobrist[them][capture][capsq];
- // If the captured piece was a pawn, update pawn hash key
- if (capture == PAWN)
- st->pawnKey ^= zobrist[them][PAWN][capsq];
-
// Update incremental scores
st->mgValue -= pst<MidGame>(them, capture, capsq);
st->egValue -= pst<EndGame>(them, capture, capsq);
- // Update material
- if (capture != PAWN)
+ // If the captured piece was a pawn, update pawn hash key,
+ // otherwise update non-pawn material.
+ if (capture == PAWN)
+ st->pawnKey ^= zobrist[them][PAWN][capsq];
+ else
st->npMaterial[them] -= piece_value_midgame(capture);
// Update material hash key
board[rto] = rook;
// Update king square
- kingSquare[us] = kto;
+ st->kingSquare[us] = kto;
// Update piece lists
pieceList[us][KING][index[kfrom]] = kto;
board[from] = piece_of_color_and_type(us, pt);
board[to] = EMPTY;
- // If the moving piece was a king, update the king square
- if (pt == KING)
- kingSquare[us] = from;
-
// Update piece list
index[from] = index[to];
pieceList[us][pt][index[from]] = from;
board[rfrom] = piece_of_color_and_type(us, ROOK);
board[kfrom] = piece_of_color_and_type(us, KING);
- // Update king square
- kingSquare[us] = kfrom;
-
// Update piece lists
pieceList[us][KING][index[kto]] = kfrom;
pieceList[us][ROOK][index[rto]] = rfrom;
pieceCount[c][pt]++;
if (pt == KING)
- kingSquare[c] = s;
+ st->kingSquare[c] = s;
}