]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Revert previous patch due to miscompile under gcc
[stockfish] / src / search.cpp
index 5a0af8f82a0700cea2a8515b414d823b8e9ae3e9..d94128eb41c944bd34ec5d92432aad714e5efce5 100644 (file)
@@ -596,7 +596,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,7 +625,7 @@ namespace {
     // Iterative deepening loop
     while (++depth <= PLY_MAX && (!MaxDepth || depth <= MaxDepth) && !StopRequest)
     {
-        Rml.bestMoveChanges = researchCountFL = researchCountFH = 0;
+        Rml.bestMoveChanges = 0;
         cout << "info depth " << depth << endl;
 
         // Calculate dynamic aspiration window based on previous iterations
@@ -643,8 +643,7 @@ 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);
 
@@ -667,20 +666,21 @@ 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];