]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Extend checks more in losing positions
[stockfish] / src / search.cpp
index 17d52cae5febf53739f97e78e0ab254e3e7d5b83..f64f55f0a129a4b4292891140ebd9eb1ad818af5 100644 (file)
@@ -242,13 +242,11 @@ void Search::think() {
   Threads.sleepWhileIdle = Options["Idle Threads Sleep"];
 
   // Set best timer interval to avoid lagging under time pressure. Timer is
-  // used to check for remaining available thinking time.
+  // used to check for remaining available thinking time. Timer will be started
+  // at the end of first iteration to avoid returning with a random move.
   Threads.timer->msec =
   Limits.use_time_management() ? std::min(100, std::max(TimeMgr.available_time() / 16, TimerResolution)) :
-                  Limits.nodes ? 2 * TimerResolution
-                               : 100;
-
-  Threads.timer->notify_one(); // Wake up the recurring timer
+                  Limits.nodes ? 2 * TimerResolution : 100;
 
   id_loop(RootPos); // Let's start searching !
 
@@ -333,7 +331,7 @@ namespace {
     while (++depth <= MAX_PLY && !Signals.stop && (!Limits.depth || depth <= Limits.depth))
     {
         // Age out PV variability metric
-        BestMoveChanges *= 0.8;
+        BestMoveChanges *= 0.8f;
 
         // Save last iteration's scores before first PV line is searched and all
         // the move scores but the (new) PV are set to -VALUE_INFINITE.
@@ -402,6 +400,10 @@ namespace {
                 assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
             }
 
+            // Wake up the recurring timer after first iteration is finished
+            if (depth == 1)
+                Threads.timer->notify_one();
+
             // Sort the PV lines searched so far and update the GUI
             std::stable_sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1);
 
@@ -780,7 +782,7 @@ moves_loop: // When in check and at SpNode search starts from here
 
     singularExtensionNode =   !RootNode
                            && !SpNode
-                           &&  depth >= (PvNode ? 6 * ONE_PLY : 8 * ONE_PLY)
+                           &&  depth >= 8 * ONE_PLY
                            &&  ttMove != MOVE_NONE
                            && !excludedMove // Recursive singular search is not allowed
                            && (tte->bound() & BOUND_LOWER)
@@ -835,7 +837,7 @@ moves_loop: // When in check and at SpNode search starts from here
           ext = ONE_PLY;
 
       else if (givesCheck && pos.see_sign(move) >= 0)
-          ext = ONE_PLY / 2;
+          ext = inCheck || ss->staticEval < VALUE_ZERO ? ONE_PLY : ONE_PLY / 2;
 
       // Singular extension search. If all moves but one fail low on a search of
       // (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move