]> git.sesse.net Git - stockfish/commitdiff
Sort again root moves after a fail low
authorMarco Costalba <mcostalba@gmail.com>
Sat, 6 Mar 2010 10:43:31 +0000 (11:43 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 6 Mar 2010 10:43:31 +0000 (11:43 +0100)
Currently we use original sorting after a fail low to
research at wider window. This patch instead sorts the
moves according to the last available move's scores.

Strangely no functional change, but should be.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index 82ecd913f8ddfec988f58f638fd52247d9c9e7f1..80764533d8926aac73c3eee0b204344ced42c455 100644 (file)
@@ -645,7 +645,6 @@ namespace {
     while (Iteration < PLY_MAX)
     {
         // Initialize iteration
     while (Iteration < PLY_MAX)
     {
         // Initialize iteration
-        rml.sort();
         Iteration++;
         BestMoveChangesByIteration[Iteration] = 0;
         if (Iteration <= 5)
         Iteration++;
         BestMoveChangesByIteration[Iteration] = 0;
         if (Iteration <= 5)
@@ -666,7 +665,7 @@ namespace {
             beta  = Min(ValueByIteration[Iteration - 1] + AspirationDelta,  VALUE_INFINITE);
         }
 
             beta  = Min(ValueByIteration[Iteration - 1] + AspirationDelta,  VALUE_INFINITE);
         }
 
-        // Search to the current depth
+        // Search to the current depth, rml is updated and sorted
         value = root_search(p, ss, rml, alpha, beta);
 
         // Write PV to transposition table, in case the relevant entries have
         value = root_search(p, ss, rml, alpha, beta);
 
         // Write PV to transposition table, in case the relevant entries have
@@ -733,8 +732,6 @@ namespace {
             break;
     }
 
             break;
     }
 
-    rml.sort();
-
     // If we are pondering or in infinite search, we shouldn't print the
     // best move before we are told to do so.
     if (!AbortSearch && (PonderSearch || InfiniteSearch))
     // If we are pondering or in infinite search, we shouldn't print the
     // best move before we are told to do so.
     if (!AbortSearch && (PonderSearch || InfiniteSearch))
@@ -808,6 +805,9 @@ namespace {
 
     while (1) // Fail low loop
     {
 
     while (1) // Fail low loop
     {
+        // Sort the moves before to (re)search
+        rml.sort();
+
         // Loop through all the moves in the root move list
         for (int i = 0; i <  rml.move_count() && !AbortSearch; i++)
         {
         // Loop through all the moves in the root move list
         for (int i = 0; i <  rml.move_count() && !AbortSearch; i++)
         {
@@ -925,7 +925,7 @@ namespace {
                 break;
 
             // Remember beta-cutoff and searched nodes counts for this move. The
                 break;
 
             // Remember beta-cutoff and searched nodes counts for this move. The
-            // info is used to sort the root moves at the next iteration.
+            // info is used to sort the root moves for the next iteration.
             int64_t our, their;
             TM.get_beta_counters(pos.side_to_move(), our, their);
             rml.set_beta_counters(i, our, their);
             int64_t our, their;
             TM.get_beta_counters(pos.side_to_move(), our, their);
             rml.set_beta_counters(i, our, their);
@@ -1002,6 +1002,9 @@ namespace {
 
     } // Fail low loop
 
 
     } // Fail low loop
 
+    // Sort the moves before to return
+    rml.sort();
+
     return alpha;
   }
 
     return alpha;
   }