X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsearch.cpp;h=74ed69ff6495b7b4a04ee84804547342192b74dd;hb=9c7d72739cffe523f0ea8c84875160c17ae6ab82;hp=702adc53dbdae3e81508f78e88c08cc12556630d;hpb=c56a7ee803bcb3c2c6072ee4ea196eb4eb9bdf00;p=stockfish diff --git a/src/search.cpp b/src/search.cpp index 702adc53..74ed69ff 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -162,7 +162,7 @@ namespace { int MultiPV, UCIMultiPV, MultiPVIdx; // Time management variables - bool StopOnPonderhit, FirstRootMove, StopRequest, QuitRequest, AspirationFailLow; + volatile bool StopOnPonderhit, FirstRootMove, StopRequest, QuitRequest, AspirationFailLow; TimeManager TimeMgr; SearchLimits Limits; @@ -465,9 +465,10 @@ bool think(Position& pos, const SearchLimits& limits, Move searchMoves[]) { pos.undo_move(bestMove); // Return from think() with unchanged position } - // If we are pondering or in infinite search, we shouldn't print the best move + // When we reach max depth we arrive here even without a StopRequest, but if + // we are pondering or in infinite search, we shouldn't print the best move // before we are told to do so. - if (Limits.ponder || Limits.infinite) + if (!StopRequest && (Limits.ponder || Limits.infinite)) wait_for_stop_or_ponderhit(); // Could be MOVE_NONE when searching on a stalemate position @@ -648,8 +649,8 @@ namespace { if (depth > 2 && bestMoveChanges[depth]) bestMoveNeverChanged = false; - // Check for some early stop condition - if (!StopRequest && Limits.useTimeManagement()) + // Do we have time for the next iteration? Can we stop searching now? + if (!StopRequest && !StopOnPonderhit && Limits.useTimeManagement()) { // Take in account some extra time if the best move has changed if (depth > 4 && depth < 50) @@ -678,7 +679,7 @@ namespace { } // If we are allowed to ponder do not stop the search now but keep pondering - if (StopRequest && Limits.ponder) + if (StopRequest && Limits.ponder) // FIXME Limits.ponder is racy { StopRequest = false; StopOnPonderhit = true; @@ -2200,8 +2201,8 @@ void do_timer_event() { static int lastInfoTime; int e = elapsed_search_time(); - // Print debug information every second - if (get_system_time() - lastInfoTime >= 1000) + // Print debug information every one second + if (!lastInfoTime || get_system_time() - lastInfoTime >= 1000) { lastInfoTime = get_system_time();