summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7c55b0e)
This avoids to reverting back when undoing the move.
No functional change. No performance change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
struct ReducedStateInfo {
Key key, pawnKey, materialKey;
int castleRights, rule50;
struct ReducedStateInfo {
Key key, pawnKey, materialKey;
int castleRights, rule50;
+ Square kingSquare[2], epSquare;
Value mgValue, egValue;
Value npMaterial[2];
};
Value mgValue, egValue;
Value npMaterial[2];
};
// If the moving piece was a king, update the king square
if (pt == KING)
// If the moving piece was a king, update the king square
if (pt == KING)
+ 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 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];
// 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 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
st->npMaterial[them] -= piece_value_midgame(capture);
// Update material hash key
board[rto] = rook;
// Update king square
board[rto] = rook;
// Update king square
+ st->kingSquare[us] = kto;
// Update piece lists
pieceList[us][KING][index[kfrom]] = kto;
// Update piece lists
pieceList[us][KING][index[kfrom]] = kto;
board[from] = piece_of_color_and_type(us, pt);
board[to] = EMPTY;
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;
// 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);
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;
// Update piece lists
pieceList[us][KING][index[kto]] = kfrom;
pieceList[us][ROOK][index[rto]] = rfrom;
pieceCount[c][pt]++;
if (pt == KING)
pieceCount[c][pt]++;
if (pt == KING)
struct StateInfo {
Key key, pawnKey, materialKey;
int castleRights, rule50;
struct StateInfo {
Key key, pawnKey, materialKey;
int castleRights, rule50;
+ Square kingSquare[2], epSquare;
Value mgValue, egValue;
Value npMaterial[2];
Value mgValue, egValue;
Value npMaterial[2];
int index[64]; // [square]
// Other info
int index[64]; // [square]
// Other info
Color sideToMove;
int gamePly;
Key history[MaxGameLength];
Color sideToMove;
int gamePly;
Key history[MaxGameLength];
}
inline Square Position::king_square(Color c) const {
}
inline Square Position::king_square(Color c) const {
+ return st->kingSquare[c];
}
inline bool Position::can_castle_kingside(Color side) const {
}
inline bool Position::can_castle_kingside(Color side) const {