]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Fix: Honour UCI "quit" command while still in the book
[stockfish] / src / search.cpp
index a73e1b80ff335183543a8ccd16acf6b14d8fdb82..6ec051987d98663a775252e74f77e52f52f8575e 100644 (file)
@@ -424,7 +424,7 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
               wait_for_stop_or_ponderhit();
 
           cout << "bestmove " << bookMove << endl;
-          return true;
+          return !QuitRequest;
       }
   }
 
@@ -1973,13 +1973,6 @@ split_point_start: // At split points actual search starts from here
     static int lastInfoTime;
     int t = current_search_time();
 
-    bool stillAtFirstMove =    FirstRootMove
-                           && !AspirationFailLow
-                           &&  t > TimeMgr.available_time();
-
-    bool noMoreTime =   t > TimeMgr.maximum_time()
-                     || stillAtFirstMove;
-
     //  Poll for input
     if (data_available())
     {
@@ -2010,8 +2003,7 @@ split_point_start: // At split points actual search starts from here
             // should continue searching but switching from pondering to normal search.
             Pondering = false;
 
-            if (   Iteration >= 3 && UseTimeManagement
-                && (noMoreTime || StopOnPonderhit))
+            if (StopOnPonderhit)
                 StopRequest = true;
         }
     }
@@ -2043,6 +2035,13 @@ split_point_start: // At split points actual search starts from here
     if (Pondering)
         return;
 
+    bool stillAtFirstMove =    FirstRootMove
+                           && !AspirationFailLow
+                           &&  t > TimeMgr.available_time();
+
+    bool noMoreTime =   t > TimeMgr.maximum_time()
+                     || stillAtFirstMove;
+
     if (   (Iteration >= 3 && UseTimeManagement && noMoreTime)
         || (ExactMaxTime && t >= ExactMaxTime)
         || (Iteration >= 3 && MaxNodes && pos.nodes_searched() >= MaxNodes))
@@ -2073,7 +2072,7 @@ split_point_start: // At split points actual search starts from here
   // the UCI protocol: When pondering, the engine is not allowed to give a
   // "bestmove" before the GUI sends it a "stop" or "ponderhit" command.
   // We simply wait here until one of these commands is sent, and return,
-  // after which the bestmove and pondermove will be printed (in id_loop()).
+  // after which the bestmove and pondermove will be printed.
 
   void wait_for_stop_or_ponderhit() {