From: mbootsector Date: Mon, 2 Nov 2015 09:58:18 +0000 (+0000) Subject: Pick bestmove from the deepest thread. X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=27c5cb59127101d834636d4faa0062d4e7bd05ce;hp=86f04dbcc08e52864c1136d713996e3a0c8d2610;ds=inline Pick bestmove from the deepest thread. STC: LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 26930 W: 4441 L: 4214 D: 18275 LTC: LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 7783 W: 1017 L: 876 D: 5890 No functional change in single thread mode Resolves #485 --- diff --git a/src/search.cpp b/src/search.cpp index 380c3342..39a73193 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -329,10 +329,22 @@ void MainThread::think() { wait(Signals.stop); } - sync_cout << "bestmove " << UCI::move(rootMoves[0].pv[0], rootPos.is_chess960()); + // Check if there are threads with a better score than main thread. + Thread* bestThread = this; + for (Thread* th : Threads) + if ( th->completedDepth > bestThread->completedDepth + && th->rootMoves[0].score > bestThread->rootMoves[0].score) + bestThread = th; + + // Send new PV when needed. + // FIXME: Breaks multiPV, and skill levels + if (bestThread != this) + sync_cout << UCI::pv(bestThread->rootPos, bestThread->completedDepth, -VALUE_INFINITE, VALUE_INFINITE) << sync_endl; - if (rootMoves[0].pv.size() > 1 || rootMoves[0].extract_ponder_from_tt(rootPos)) - std::cout << " ponder " << UCI::move(rootMoves[0].pv[1], rootPos.is_chess960()); + sync_cout << "bestmove " << UCI::move(bestThread->rootMoves[0].pv[0], rootPos.is_chess960()); + + if (bestThread->rootMoves[0].pv.size() > 1 || bestThread->rootMoves[0].extract_ponder_from_tt(rootPos)) + std::cout << " ponder " << UCI::move(bestThread->rootMoves[0].pv[1], rootPos.is_chess960()); std::cout << sync_endl; } @@ -352,6 +364,7 @@ void Thread::search(bool isMainThread) { bestValue = delta = alpha = -VALUE_INFINITE; beta = VALUE_INFINITE; + completedDepth = DEPTH_ZERO; if (isMainThread) { @@ -472,6 +485,9 @@ void Thread::search(bool isMainThread) { sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl; } + if (!Signals.stop) + completedDepth = rootDepth; + if (!isMainThread) continue; diff --git a/src/thread.h b/src/thread.h index c1e55322..fd7343a8 100644 --- a/src/thread.h +++ b/src/thread.h @@ -76,6 +76,7 @@ struct Thread : public ThreadBase { Depth rootDepth; HistoryStats history; MovesStats counterMoves; + Depth completedDepth; };