if (rootMoves.empty())
{
- rootMoves.push_back(RootMove(MOVE_NONE));
+ rootMoves.emplace_back(MOVE_NONE);
sync_cout << "info depth 0 score "
<< UCI::value(rootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
<< sync_endl;
// the UCI protocol states that we shouldn't print the best move before the
// GUI sends a "stop" or "ponderhit" command. We therefore simply wait here
// until the GUI sends one of those commands (which also raises Threads.stop).
- if (!Threads.stop && (Limits.ponder || Limits.infinite))
- {
- Threads.stopOnPonderhit = true;
- wait(Threads.stop);
- }
+ Threads.stopOnPonderhit = true;
+
+ while (!Threads.stop && (Threads.ponder || Limits.infinite))
+ {} // Busy wait for a stop or a ponder reset
- // Stop the threads if not already stopped
+ // Stop the threads if not already stopped (also raise the stop if
+ // "ponderhit" just reset Threads.ponder).
Threads.stop = true;
// Wait until all threads have finished
bestValue = delta = alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
- completedDepth = DEPTH_ZERO;
if (mainThread)
{
{
// If we are allowed to ponder do not stop the search now but
// keep pondering until the GUI sends "ponderhit" or "stop".
- if (Limits.ponder)
+ if (Threads.ponder)
Threads.stopOnPonderhit = true;
else
Threads.stop = true;
}
// An engine may not stop pondering until told so by the GUI
- if (Limits.ponder)
+ if (Threads.ponder)
return;
if ( (Limits.use_time_management() && elapsed > Time.maximum() - 10)