]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Speculative prefetch
[stockfish] / src / position.cpp
index 23370ca3f73d4ed8fedbd14595c8b30af2b332b7..b2d46b83a6a3b3d19494f2f0c424cd0df8188905 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "bitcount.h"
 #include "movegen.h"
+#include "notation.h"
 #include "position.h"
 #include "psqtab.h"
 #include "rkiss.h"
@@ -1014,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.
@@ -1116,10 +1132,6 @@ Value Position::see(Move m) const {
 
 bool Position::is_draw() const {
 
-  if (   !pieces(PAWN)
-      && (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
-      return true;
-
   if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
       return true;