]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Fix pruning to (in TB loss) in Null move pruning.
[stockfish] / src / search.cpp
index 5de950eb147dc2d5a64080055b097b1a3eeb60f8..8bd5ec9b48bc4b48b244a97bb2d2a92a93dc6d4f 100644 (file)
@@ -782,7 +782,8 @@ namespace {
         &&  ss->staticEval >= beta - 21 * depth - improvement / 13 + 258
         && !excludedMove
         &&  pos.non_pawn_material(us)
-        && (ss->ply >= thisThread->nmpMinPly))
+        &&  ss->ply >= thisThread->nmpMinPly
+        &&  beta > VALUE_TB_LOSS_IN_MAX_PLY)
     {
         assert(eval - beta >= 0);
 
@@ -801,10 +802,9 @@ namespace {
         if (nullValue >= beta)
         {
             // Do not return unproven mate or TB scores
-            if (nullValue >= VALUE_TB_WIN_IN_MAX_PLY)
-                nullValue = beta;
+            nullValue = std::min(nullValue, VALUE_TB_WIN_IN_MAX_PLY-1);
 
-            if (thisThread->nmpMinPly || (abs(beta) < VALUE_KNOWN_WIN && depth < 14))
+            if (thisThread->nmpMinPly || depth < 14)
                 return nullValue;
 
             assert(!thisThread->nmpMinPly); // Recursive verification is not allowed
@@ -1098,6 +1098,10 @@ moves_loop: // When in check, search starts here
               else if (ttValue >= beta)
                   extension = -2 - !PvNode;
 
+              // If we are on a cutNode, reduce it based on depth (negative extension) (~1 Elo)
+              else if (cutNode)
+                  extension = depth > 8 && depth < 17 ? -3 : -1;
+
               // If the eval of ttMove is less than value, we reduce it (negative extension) (~1 Elo)
               else if (ttValue <= value)
                   extension = -1;
@@ -1463,9 +1467,7 @@ moves_loop: // When in check, search starts here
 
     // Step 4. Static evaluation of the position
     if (ss->inCheck)
-    {
         bestValue = futilityBase = -VALUE_INFINITE;
-    }
     else
     {
         if (ss->ttHit)
@@ -1480,11 +1482,9 @@ moves_loop: // When in check, search starts here
                 bestValue = ttValue;
         }
         else
-        {
             // In case of null move search use previous static eval with a different sign
             ss->staticEval = bestValue = (ss-1)->currentMove != MOVE_NULL ? evaluate(pos)
                                                                           : -(ss-1)->staticEval;
-        }
 
         // Stand pat. Return immediately if static value is at least beta
         if (bestValue >= beta)
@@ -1559,23 +1559,23 @@ moves_loop: // When in check, search starts here
                     bestValue = std::max(bestValue, futilityBase);
                     continue;
                 }
-        }
-
-        // We prune after the second quiet check evasion move, where being 'in check' is
-        // implicitly checked through the counter, and being a 'quiet move' apart from
-        // being a tt move is assumed after an increment because captures are pushed ahead.
-        if (quietCheckEvasions > 1)
-            break;
-
-        // Continuation history based pruning (~3 Elo)
-        if (   !capture
-            && (*contHist[0])[pos.moved_piece(move)][to_sq(move)] < 0
-            && (*contHist[1])[pos.moved_piece(move)][to_sq(move)] < 0)
-            continue;
+            }
 
-        // Do not search moves with bad enough SEE values (~5 Elo)
-        if (!pos.see_ge(move, Value(-95)))
-            continue;
+            // We prune after the second quiet check evasion move, where being 'in check' is
+            // implicitly checked through the counter, and being a 'quiet move' apart from
+            // being a tt move is assumed after an increment because captures are pushed ahead.
+            if (quietCheckEvasions > 1)
+                break;
+
+            // Continuation history based pruning (~3 Elo)
+            if (   !capture
+                && (*contHist[0])[pos.moved_piece(move)][to_sq(move)] < 0
+                && (*contHist[1])[pos.moved_piece(move)][to_sq(move)] < 0)
+                continue;
+
+            // Do not search moves with bad enough SEE values (~5 Elo)
+            if (!pos.see_ge(move, Value(-95)))
+                continue;
         }
 
         // Speculative prefetch as early as possible