X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=b2d46b83a6a3b3d19494f2f0c424cd0df8188905;hp=b00bda24b0596b56a4661a315cfebc2e6c0195e0;hb=82d065b011e416d655167864e4939ce84f0521e5;hpb=e60cdca9b016f1edb8789d99785843cebe704e29 diff --git a/src/position.cpp b/src/position.cpp index b00bda24..b2d46b83 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1015,6 +1015,21 @@ 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::see() is a static exchange evaluator: It tries to estimate the /// material gain or loss resulting from a move.