]> git.sesse.net Git - stockfish/commitdiff
Don't exit earlier from aspiration window loop
authorMarco Costalba <mcostalba@gmail.com>
Mon, 10 Sep 2012 16:24:53 +0000 (18:24 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 14 Sep 2012 08:05:46 +0000 (10:05 +0200)
Currently we exit the loop when

abs(bestValue) >= VALUE_KNOWN_WIN

but there is no logical reason for this. It seems more
natural to re-search again with full open window.

This has practically no impact in most cases, we have a
'no functional change' running 'bench' command.

src/search.cpp

index 219c10aad7eda8a840bb8338e9d5dc3110a9dc53..eeca97389fad2bf6b63a2a1436a0c18069f9148d 100644 (file)
@@ -365,7 +365,8 @@ namespace {
 
             // Start with a small aspiration window and, in case of fail high/low,
             // research with bigger window until not failing high/low anymore.
 
             // Start with a small aspiration window and, in case of fail high/low,
             // research with bigger window until not failing high/low anymore.
-            do {
+            while (true)
+            {
                 // Search starts from ss+1 to allow referencing (ss-1). This is
                 // needed by update gains and ss copy when splitting at Root.
                 bestValue = search<Root>(pos, ss+1, alpha, beta, depth * ONE_PLY);
                 // Search starts from ss+1 to allow referencing (ss-1). This is
                 // needed by update gains and ss copy when splitting at Root.
                 bestValue = search<Root>(pos, ss+1, alpha, beta, depth * ONE_PLY);
@@ -419,9 +420,15 @@ namespace {
                 else
                     break;
 
                 else
                     break;
 
-                assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
+                // Search with full window in case we have a win/mate score
+                if (abs(bestValue) >= VALUE_KNOWN_WIN)
+                {
+                    alpha = -VALUE_INFINITE;
+                    beta  =  VALUE_INFINITE;
+                }
 
 
-            } while (abs(bestValue) < VALUE_KNOWN_WIN);
+                assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
+            }
         }
 
         // Skills: Do we need to pick now the best move ?
         }
 
         // Skills: Do we need to pick now the best move ?