X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=cbaa07e86e6c7925aa810347fc63688f63810252;hp=b00bda24b0596b56a4661a315cfebc2e6c0195e0;hb=15e21911110f9d459c4fef2bb17903d97345d0b9;hpb=a1b62d68ec59aae504a9e39bfd3a7dfa4a831d29 diff --git a/src/position.cpp b/src/position.cpp index b00bda24..cbaa07e8 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -807,9 +807,6 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI st->castlingRights &= ~cr; } - // Prefetch TT access as soon as we know the new hash key - prefetch((char*)TT.first_entry(k)); - // Move the piece. The tricky Chess960 castling is handled earlier if (type_of(m) != CASTLING) move_piece(from, to, us, pt); @@ -1016,6 +1013,26 @@ void Position::undo_null_move() { } +/// 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.