]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Sync history and counter moves updating
[stockfish] / src / search.cpp
index 6aa1081f435e0cd666dc8ba3ba0dfcfdc2ebb245..cf791334e5b583e415f4ac11c0f72a2f2b3c4c34 100644 (file)
@@ -569,13 +569,26 @@ namespace {
         TT.refresh(tte);
         ss->currentMove = ttMove; // Can be MOVE_NONE
 
+        // Update killers, history, and counter move on TT hit
         if (    ttValue >= beta
             &&  ttMove
             && !pos.capture_or_promotion(ttMove)
-            &&  ttMove != ss->killers[0])
+            && !inCheck)
         {
-            ss->killers[1] = ss->killers[0];
-            ss->killers[0] = ttMove;
+            if (ss->killers[0] != ttMove)
+            {
+                ss->killers[1] = ss->killers[0];
+                ss->killers[0] = ttMove;
+            }
+
+            Value bonus = Value(int(depth) * int(depth));
+            History.update(pos.moved_piece(ttMove), to_sq(ttMove), bonus);
+
+            if (is_ok((ss-1)->currentMove))
+            {
+                Square prevMoveSq = to_sq((ss-1)->currentMove);
+                Countermoves.update(pos.piece_on(prevMoveSq), prevMoveSq, ttMove);
+            }
         }
         return ttValue;
     }
@@ -933,6 +946,13 @@ moves_loop: // When in check and at SpNode search starts from here
 
           value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);
 
+          // Research at intermediate depth if reduction is very high
+          if (value > alpha && ss->reduction >= 4 * ONE_PLY)
+          {
+              Depth d2 = std::max(newDepth - 2 * ONE_PLY, ONE_PLY);
+              value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d2, true);
+          }
+
           doFullDepthSearch = (value > alpha && ss->reduction != DEPTH_ZERO);
           ss->reduction = DEPTH_ZERO;
       }