X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=7b3fd18bb03cd66df479dd50ca7ec7c84b6226e6;hp=11dcdb34f13840a1b8ff43a7b08df4273fe972f9;hb=daf0fe1f57337d33f9e0af5a8aa8ef0868b20417;hpb=750dfa0521472e86c67f870fe7ca413d670cafe2 diff --git a/src/search.cpp b/src/search.cpp index 11dcdb34..7b3fd18b 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -253,7 +253,7 @@ void MainThread::search() { 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; @@ -277,13 +277,13 @@ void MainThread::search() { // 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 @@ -341,7 +341,6 @@ void Thread::search() { bestValue = delta = alpha = -VALUE_INFINITE; beta = VALUE_INFINITE; - completedDepth = DEPTH_ZERO; if (mainThread) { @@ -499,7 +498,7 @@ void Thread::search() { { // 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; @@ -1489,10 +1488,10 @@ moves_loop: // When in check search starts from here } // 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) + if ( (Limits.use_time_management() && elapsed > Time.maximum()) || (Limits.movetime && elapsed >= Limits.movetime) || (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes)) Threads.stop = true;