mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00: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:
parent
4b926f227d
commit
74829342ef
3 changed files with 23 additions and 18 deletions
|
@ -1015,22 +1015,27 @@ void Position::undo_null_move() {
|
||||||
sideToMove = ~sideToMove;
|
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);
|
/// Position::key_after() computes the new hash key after the given moven. Needed
|
||||||
int to = to_sq(m);
|
/// for speculative prefetch. It doesn't recognize special moves like castling,
|
||||||
Piece p = board[from];
|
/// en-passant and promotions.
|
||||||
Piece capP = board[to];
|
|
||||||
Key ret = st->key ^ Zobrist::side;
|
Key Position::key_after(Move m) const {
|
||||||
if (capP != NO_PIECE)
|
|
||||||
ret ^= Zobrist::psq[color_of(capP)][type_of(capP)][to];
|
Color us = sideToMove;
|
||||||
ret ^= Zobrist::psq[color_of(p)][type_of(p)][to];
|
Square from = from_sq(m);
|
||||||
ret ^= Zobrist::psq[color_of(p)][type_of(p)][from];
|
Square to = to_sq(m);
|
||||||
return ret;
|
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
|
/// Position::see() is a static exchange evaluator: It tries to estimate the
|
||||||
/// material gain or loss resulting from a move.
|
/// material gain or loss resulting from a move.
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,6 @@ public:
|
||||||
void undo_move(Move m);
|
void undo_move(Move m);
|
||||||
void do_null_move(StateInfo& st);
|
void do_null_move(StateInfo& st);
|
||||||
void undo_null_move();
|
void undo_null_move();
|
||||||
Key hash_after_move(Move m) const;
|
|
||||||
|
|
||||||
// Static exchange evaluation
|
// Static exchange evaluation
|
||||||
Value see(Move m) const;
|
Value see(Move m) const;
|
||||||
|
@ -147,6 +146,7 @@ public:
|
||||||
|
|
||||||
// Accessing hash keys
|
// Accessing hash keys
|
||||||
Key key() const;
|
Key key() const;
|
||||||
|
Key key_after(Move m) const;
|
||||||
Key exclusion_key() const;
|
Key exclusion_key() const;
|
||||||
Key pawn_key() const;
|
Key pawn_key() const;
|
||||||
Key material_key() const;
|
Key material_key() const;
|
||||||
|
|
|
@ -788,8 +788,8 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Speculative prefetch
|
// Speculative prefetch as early as possible
|
||||||
prefetch((char*)TT.first_entry(pos.hash_after_move(move)));
|
prefetch((char*)TT.first_entry(pos.key_after(move)));
|
||||||
|
|
||||||
// Check for legality just before making the move
|
// Check for legality just before making the move
|
||||||
if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
|
if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
|
||||||
|
@ -1140,8 +1140,8 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
&& pos.see_sign(move) < VALUE_ZERO)
|
&& pos.see_sign(move) < VALUE_ZERO)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Speculative prefetch
|
// Speculative prefetch as early as possible
|
||||||
prefetch((char*)TT.first_entry(pos.hash_after_move(move)));
|
prefetch((char*)TT.first_entry(pos.key_after(move)));
|
||||||
|
|
||||||
// Check for legality just before making the move
|
// Check for legality just before making the move
|
||||||
if (!pos.legal(move, ci.pinned))
|
if (!pos.legal(move, ci.pinned))
|
||||||
|
|
Loading…
Add table
Reference in a new issue