]> git.sesse.net Git - stockfish/commitdiff
Fix last search info carried over to mate position
authorNiklas Fiekas <niklas.fiekas@backscattering.de>
Fri, 8 Apr 2016 15:20:47 +0000 (17:20 +0200)
committerJoona Kiiski <joona@zoox.com>
Sat, 16 Apr 2016 09:22:36 +0000 (10:22 +0100)
When starting search in a mate or stalemate position, Stockfish does not
even care to reinitialize and start worker threads. However after search
all threads are checked for the best move.

This can lead to bestmove and info beeing carried over from the last
search.

Example session:

    setoption name threads value 7
    go movetime 4000
    position startpos moves f2f3 e7e5 g2g4 d8h4
    go movetime 4000

Actual output is like (almost always):

    [...]
    bestmove e2e4
    info depth 0 score mate 0
    info depth 20 seldepth 29 multipv 1 score cp 28 [...] pv e2e4
    bestmove e2e4

Expected output / output after fix:

    [...]
    bestmove e2e4 ponder e7e6
    info depth 0 score mate 0
    bestmove (none)

Resolves #623

src/search.cpp

index dc488c2b8922df283d51ba1c525e452b83cab7e4..10d491c025e7e9a2383472b812010f9a5dc74839 100644 (file)
@@ -359,7 +359,8 @@ void MainThread::search() {
   Thread* bestThread = this;
   if (   !this->easyMovePlayed
       &&  Options["MultiPV"] == 1
-      && !Skill(Options["Skill Level"]).enabled())
+      && !Skill(Options["Skill Level"]).enabled()
+      &&  rootMoves[0].pv[0] != MOVE_NONE)
   {
       for (Thread* th : Threads)
           if (   th->completedDepth > bestThread->completedDepth