mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Reformat and rename hash_after_move()
Align to standard coding style and properly use enum types. Rename while there. No functional change.
This commit is contained in:
committed by
Joona Kiiski
parent
4b926f227d
commit
74829342ef
@@ -1015,22 +1015,27 @@ void Position::undo_null_move() {
|
||||
sideToMove = ~sideToMove;
|
||||
}
|
||||
|
||||
// Position::hash_after_move() updates the hash key needed for the speculative prefetch.
|
||||
// It doesn't recognize special moves like castling, en-passant and promotions.
|
||||
Key Position::hash_after_move(Move m) const {
|
||||
|
||||
int from = from_sq(m);
|
||||
int to = to_sq(m);
|
||||
Piece p = board[from];
|
||||
Piece capP = board[to];
|
||||
Key ret = st->key ^ Zobrist::side;
|
||||
if (capP != NO_PIECE)
|
||||
ret ^= Zobrist::psq[color_of(capP)][type_of(capP)][to];
|
||||
ret ^= Zobrist::psq[color_of(p)][type_of(p)][to];
|
||||
ret ^= Zobrist::psq[color_of(p)][type_of(p)][from];
|
||||
return ret;
|
||||
/// Position::key_after() computes the new hash key after the given moven. Needed
|
||||
/// for speculative prefetch. It doesn't recognize special moves like castling,
|
||||
/// en-passant and promotions.
|
||||
|
||||
Key Position::key_after(Move m) const {
|
||||
|
||||
Color us = sideToMove;
|
||||
Square from = from_sq(m);
|
||||
Square to = to_sq(m);
|
||||
PieceType pt = type_of(piece_on(from));
|
||||
PieceType captured = type_of(piece_on(to));
|
||||
Key k = st->key ^ Zobrist::side;
|
||||
|
||||
if (captured)
|
||||
k ^= Zobrist::psq[~us][captured][to];
|
||||
|
||||
return k ^ Zobrist::psq[us][pt][to] ^ Zobrist::psq[us][pt][from];
|
||||
}
|
||||
|
||||
|
||||
/// Position::see() is a static exchange evaluator: It tries to estimate the
|
||||
/// material gain or loss resulting from a move.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user