]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Fix a compile error with icc
[stockfish] / src / search.cpp
index 5a0af8f82a0700cea2a8515b414d823b8e9ae3e9..c393b75b5e4a4ba75998b96c85c5b8316ca0d2fd 100644 (file)
@@ -578,8 +578,15 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
   if (!StopRequest && (Pondering || InfiniteSearch))
       wait_for_stop_or_ponderhit();
 
-  // Could be both MOVE_NONE when searching on a stalemate position
-  cout << "bestmove " << bestMove << " ponder " << ponderMove << endl;
+  // Could be MOVE_NONE when searching on a stalemate position
+  cout << "bestmove " << bestMove;
+
+  // UCI protol is not clear on allowing sending an empty ponder move, instead
+  // it is clear that ponder move is optional. So skip it if empty.
+  if (ponderMove != MOVE_NONE)
+      cout << " ponder " << ponderMove;
+
+  cout << endl;
 
   return !QuitRequest;
 }
@@ -596,7 +603,7 @@ namespace {
     SearchStack ss[PLY_MAX_PLUS_2];
     Value bestValues[PLY_MAX_PLUS_2];
     int bestMoveChanges[PLY_MAX_PLUS_2];
-    int depth, researchCountFL, researchCountFH, aspirationDelta;
+    int depth, aspirationDelta;
     Value value, alpha, beta;
     Move bestMove, easyMove;
 
@@ -625,8 +632,8 @@ namespace {
     // Iterative deepening loop
     while (++depth <= PLY_MAX && (!MaxDepth || depth <= MaxDepth) && !StopRequest)
     {
-        Rml.bestMoveChanges = researchCountFL = researchCountFH = 0;
-        cout << "info depth " << depth << endl;
+        Rml.bestMoveChanges = 0;
+        cout << set960(pos.is_chess960()) << "info depth " << depth << endl;
 
         // Calculate dynamic aspiration window based on previous iterations
         if (MultiPV == 1 && depth >= 5 && abs(bestValues[depth - 1]) < VALUE_KNOWN_WIN)
@@ -643,19 +650,14 @@ namespace {
 
         // Start with a small aspiration window and, in case of fail high/low,
         // research with bigger window until not failing high/low anymore.
-        while (true)
-        {
+        do {
             // Search starting from ss+1 to allow calling update_gains()
             value = search<PV, false, true>(pos, ss+1, alpha, beta, depth * ONE_PLY, 0);
 
-            // Send PV line to GUI and write to transposition table in case the
-            // relevant entries have been overwritten during the search.
+            // Write PV back to transposition table in case the relevant entries
+            // have been overwritten during the search.
             for (int i = 0; i < Min(MultiPV, (int)Rml.size()); i++)
-            {
                 Rml[i].insert_pv_in_tt(pos);
-                cout << set960(pos.is_chess960())
-                     << Rml[i].pv_info_to_uci(pos, depth, alpha, beta, i) << endl;
-            }
 
             // Value cannot be trusted. Break out immediately!
             if (StopRequest)
@@ -667,26 +669,31 @@ namespace {
             // otherwise exit the fail high/low loop.
             if (value >= beta)
             {
-                beta = Min(beta + aspirationDelta * (1 << researchCountFH), VALUE_INFINITE);
-                researchCountFH++;
+                beta = Min(beta + aspirationDelta, VALUE_INFINITE);
+                aspirationDelta += aspirationDelta / 2;
             }
             else if (value <= alpha)
             {
                 AspirationFailLow = true;
                 StopOnPonderhit = false;
 
-                alpha = Max(alpha - aspirationDelta * (1 << researchCountFL), -VALUE_INFINITE);
-                researchCountFL++;
+                alpha = Max(alpha - aspirationDelta, -VALUE_INFINITE);
+                aspirationDelta += aspirationDelta / 2;
             }
             else
                 break;
-        }
+
+        } while (abs(value) < VALUE_KNOWN_WIN);
 
         // Collect info about search result
         bestMove = Rml[0].pv[0];
         bestValues[depth] = value;
         bestMoveChanges[depth] = Rml.bestMoveChanges;
 
+        // Send PV line to GUI and to log file
+        for (int i = 0; i < Min(MultiPV, (int)Rml.size()); i++)
+            cout << Rml[i].pv_info_to_uci(pos, depth, alpha, beta, i) << endl;
+
         if (UseLogFile)
             LogFile << pretty_pv(pos, depth, value, current_search_time(), Rml[0].pv) << endl;
 
@@ -1049,7 +1056,7 @@ split_point_start: // At split points actual search starts from here
 
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
-              Value b = ttValue - depth;
+              Value b = ttValue - int(depth);
               ss->excludedMove = move;
               ss->skipNullMove = true;
               Value v = search<NonPV>(pos, ss, b - 1, b, depth / 2, ply);