From: Marco Costalba Date: Sat, 9 Nov 2013 18:04:51 +0000 (+0100) Subject: Fix printing of incorrect PV in some cases X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=e4d34e18153c953e63c49dc1c9dfd8ccdaa259f0 Fix printing of incorrect PV in some cases 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. --- diff --git a/src/search.cpp b/src/search.cpp index b7a242f9..ecfaaa56 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -325,7 +325,7 @@ namespace { 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) @@ -354,11 +354,11 @@ namespace { 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) - return; + break; // 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? - 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