]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Reduce big time spikes by reducing PV re-searches.
[stockfish] / src / search.cpp
index ab58ca648cfa802777d69f54eabf644f3f01966b..65ed9b73ffb0886e8e049a329587021c1965e466 100644 (file)
@@ -565,6 +565,7 @@ namespace {
 
     constexpr bool PvNode = NT == PV;
     const bool rootNode = PvNode && ss->ply == 0;
+    const Depth maxNextDepth = rootNode ? depth : depth + 1;
 
     // Check if we have an upcoming move which draws by repetition, or
     // if the opponent had an alternative move earlier to this position.
@@ -1259,7 +1260,8 @@ moves_loop: // When in check, search starts from here
           (ss+1)->pv = pv;
           (ss+1)->pv[0] = MOVE_NONE;
 
-          value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, false);
+          value = -search<PV>(pos, ss+1, -beta, -alpha,
+                              std::min(maxNextDepth, newDepth), false);
       }
 
       // Step 18. Undo move