]> git.sesse.net Git - stockfish/commitdiff
Ensure printing UCI info in multi-pv case
authorMarco Costalba <mcostalba@gmail.com>
Sat, 2 Aug 2014 09:02:13 +0000 (11:02 +0200)
committerlucasart <lucas.braesch@gmail.com>
Sat, 2 Aug 2014 14:16:45 +0000 (22:16 +0800)
After commit 94b1bbb68be6b0bc3aaf1cb804841a022bcc7007, in case available root moves are less than multiPV, we
could never reach condition:

PVIdx + 1 == multiPV

and as a consequence UCI output is not printed.

Fixed suggested by Joerg Oster.

No functional change.

src/search.cpp

index 3b7fab5f31fb0196db17be3cb31f92ab93c2dda2..3fb1345a892a9f7937135290fc60146a86ec8e33 100644 (file)
@@ -301,7 +301,7 @@ namespace {
             RootMoves[i].prevScore = RootMoves[i].score;
 
         // MultiPV loop. We perform a full root search for each PV line
-        for (PVIdx = 0; PVIdx < multiPV && PVIdx < RootMoves.size() && !Signals.stop; ++PVIdx)
+        for (PVIdx = 0; PVIdx < std::min(multiPV, RootMoves.size()) && !Signals.stop; ++PVIdx)
         {
             // Reset aspiration window starting size
             if (depth >= 5)
@@ -366,7 +366,7 @@ namespace {
             // Sort the PV lines searched so far and update the GUI
             std::stable_sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1);
 
-            if (PVIdx + 1 == multiPV || Time::now() - SearchTime > 3000)
+            if (PVIdx + 1 == std::min(multiPV, RootMoves.size()) || Time::now() - SearchTime > 3000)
                 sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
         }