]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Drop OnlyMoveExt PV-condition from 8 plies to 6 plies
[stockfish] / src / search.cpp
index 5d803949112423dfe4b3ebe1570437d945b6b1c2..95d8be98bc858cad282f233abf5dad0b011eb3fc 100644 (file)
@@ -1121,7 +1121,14 @@ namespace {
         return alpha;
 
     // Transposition table lookup. At PV nodes, we don't use the TT for
-    // pruning, but only for move ordering.
+    // pruning, but only for move ordering. This is to avoid problems in
+    // the following areas:
+    //
+    // * Repetition draw detection
+    // * Fifty move rule detection
+    // * Searching for a mate
+    // * Printing of full PV line
+    //
     tte = TT.retrieve(pos.get_key());
     ttMove = (tte ? tte->move() : MOVE_NONE);
 
@@ -1130,6 +1137,10 @@ namespace {
     {
         search_pv(pos, ss, alpha, beta, depth-2*OnePly, ply, threadID);
         ttMove = ss[ply].pv[ply];
+        tte = TT.retrieve(pos.get_key());
+
+        // If tte->move() != MOVE_NONE then it equals ttMove
+        assert(!(tte && tte->move()) || tte->move() == ttMove);
     }
 
     // Initialize a MovePicker object for the current position, and prepare
@@ -1158,8 +1169,9 @@ namespace {
       // To verify this we do a reduced search on all the other moves but the ttMove,
       // if result is lower then TT value minus a margin then we assume ttMove is the
       // only one playable. It is a kind of relaxed single reply extension.
-      if (   depth >= 8 * OnePly
-          && move == ttMove
+      if (   depth >= 6 * OnePly
+          && tte
+          && move == tte->move()
           && ext < OnePly
           && is_lower_bound(tte->type())
           && tte->depth() >= depth - 3 * OnePly)
@@ -1168,7 +1180,7 @@ namespace {
 
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
-              Value excValue = search(pos, ss, ttValue - SingleReplyMargin, depth / 2, ply, false, threadID, ttMove);
+              Value excValue = search(pos, ss, ttValue - SingleReplyMargin, depth / 2, ply, false, threadID, move);
 
               // If search result is well below the foreseen score of the ttMove then we
               // assume ttMove is the only one realistically playable and we extend it.
@@ -1423,6 +1435,7 @@ namespace {
     {
         search(pos, ss, beta, Min(depth/2, depth-2*OnePly), ply, false, threadID);
         ttMove = ss[ply].pv[ply];
+        tte = TT.retrieve(pos.get_key());
     }
 
     // Initialize a MovePicker object for the current position, and prepare
@@ -1461,8 +1474,9 @@ namespace {
       // if result is lower then TT value minus a margin then we assume ttMove is the
       // only one playable. It is a kind of relaxed single reply extension.
       if (   depth >= 8 * OnePly
-          && !excludedMove // do not allow recursive single-reply search
-          && move == ttMove
+          && tte
+          && move == tte->move()
+          && !excludedMove // Do not allow recursive single-reply search
           && ext < OnePly
           && is_lower_bound(tte->type())
           && tte->depth() >= depth - 3 * OnePly)
@@ -1471,7 +1485,7 @@ namespace {
 
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
-              Value excValue = search(pos, ss, ttValue - SingleReplyMargin, depth / 2, ply, false, threadID, ttMove);
+              Value excValue = search(pos, ss, ttValue - SingleReplyMargin, depth / 2, ply, false, threadID, move);
 
               // If search result is well below the foreseen score of the ttMove then we
               // assume ttMove is the only one realistically playable and we extend it.