]> git.sesse.net Git - stockfish/commitdiff
Fix printing of incorrect PV in some cases
authorMarco Costalba <mcostalba@gmail.com>
Sat, 9 Nov 2013 18:04:51 +0000 (19:04 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 9 Nov 2013 18:05:43 +0000 (19:05 +0100)
As, Gary (that analyzed the bug) says:

SF does not print a PV when the original best move fails low,
we hit our time allowance, and stop the search.  The output from
the SF search is below.  It was failing low on Ne1 at depth 34.
Then, we get bestmove Qd3, but no PV change.

info depth 34 seldepth 45 score cp 38 upperbound nodes 483484489 nps 15464575 time 31264 multipv 1 pv f3e1 h5h4 e1d3 h4g3 f2g3 a6f6 f1f6 e7f6 d1a4 f6e7 a1f1 d8f8 a4b3 b7b6 b3c2 f7f6 c2a4 h3g5 b2b3 g5f7 a4c6 f7d6 h1g2 f6f5 e4f5 d6f5
info depth 34 seldepth 45 score cp 38 upperbound nodes 483484489 nps 15464575 time 31264 multipv 1 pv f3e1 h5h4 e1d3 h4g3 f2g3 a6f6 f1f6 e7f6 d1a4 f6e7 a1f1 d8f8 a4b3 b7b6 b3c2 f7f6 c2a4 h3g5 b2b3 g5f7 a4c6 f7d6 h1g2 f6f5 e4f5 d6f5
info depth 34 seldepth 47 score cp 30 upperbound nodes 2112334132 nps 17255517 time 122415 multipv 1 pv f3e1 h5h4 d1a4 a6f6 e1d3 d8f8 a4c2 h4g3 f2g3 f6f1 a1f1 h7g8 b2b3 f7f6 a3a4 b7b6
info depth 34 seldepth 47 score cp 30 upperbound nodes 2112334132 nps 17255517 time 122415 multipv 1 pv f3e1 h5h4 d1a4 a6f6 e1d3 d8f8 a4c2 h4g3 f2g3 f6f1 a1f1 h7g8 b2b3 f7f6 a3a4 b7b6
info nodes 18235667001 time 969824
bestmove e2d3 ponder c8d7

Looking at the code, if we hit Signals.stop, we return from id_loop
before printing any PV.  It is possible for us to have resorted the
RootMove list though, which will change the move that is actually
played.

No functional change.

src/search.cpp

index b7a242f98470422cfeacd7041cefdd917d3fe7fc..ecfaaa569dfac037a0060187be323d355c37b751 100644 (file)
@@ -325,7 +325,7 @@ namespace {
             RootMoves[i].prevScore = RootMoves[i].score;
 
         // MultiPV loop. We perform a full root search for each PV line
             RootMoves[i].prevScore = RootMoves[i].score;
 
         // MultiPV loop. We perform a full root search for each PV line
-        for (PVIdx = 0; PVIdx < PVSize; ++PVIdx)
+        for (PVIdx = 0; PVIdx < PVSize && !Signals.stop; ++PVIdx)
         {
             // Reset aspiration window starting size
             if (depth >= 5)
         {
             // Reset aspiration window starting size
             if (depth >= 5)
@@ -354,11 +354,11 @@ namespace {
                 for (size_t i = 0; i <= PVIdx; ++i)
                     RootMoves[i].insert_pv_in_tt(pos);
 
                 for (size_t i = 0; i <= PVIdx; ++i)
                     RootMoves[i].insert_pv_in_tt(pos);
 
-                // If search has been stopped return immediately. Sorting and
+                // If search has been stopped break immediately. Sorting and
                 // writing PV back to TT is safe becuase RootMoves is still
                 // valid, although refers to previous iteration.
                 if (Signals.stop)
                 // writing PV back to TT is safe becuase RootMoves is still
                 // valid, although refers to previous iteration.
                 if (Signals.stop)
-                    return;
+                    break;
 
                 // When failing high/low give some update (without cluttering
                 // the UI) before to research.
 
                 // When failing high/low give some update (without cluttering
                 // the UI) before to research.
@@ -415,7 +415,7 @@ namespace {
             Signals.stop = true;
 
         // Do we have time for the next iteration? Can we stop searching now?
             Signals.stop = true;
 
         // Do we have time for the next iteration? Can we stop searching now?
-        if (Limits.use_time_management() && !Signals.stopOnPonderhit)
+        if (Limits.use_time_management() && !Signals.stop && !Signals.stopOnPonderhit)
         {
             bool stop = false; // Local variable, not the volatile Signals.stop
 
         {
             bool stop = false; // Local variable, not the volatile Signals.stop