X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=35110538170c5cb03732a955b1cbe4b616eb7dc2;hp=1e133447d381b547f97d9ea93ab7aa7321d862f7;hb=784263596ff9b01187341274b6f3cbd8971a2d2c;hpb=16566a8fcf76b9b72b6e746f318f77045df90017 diff --git a/src/search.cpp b/src/search.cpp index 1e133447..35110538 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -556,9 +556,11 @@ void Thread::search() { } double bestMoveInstability = 1 + totBestMoveChanges / Threads.size(); - // Stop the search if we have only one legal move, or if available time elapsed - if ( rootMoves.size() == 1 - || Time.elapsed() > Time.optimum() * fallingEval * reduction * bestMoveInstability) + double totalTime = rootMoves.size() == 1 ? 0 : + Time.optimum() * fallingEval * reduction * bestMoveInstability; + + // Stop the search if we have exceeded the totalTime, at least 1ms search. + if (Time.elapsed() > totalTime) { // If we are allowed to ponder do not stop the search now but // keep pondering until the GUI sends "ponderhit" or "stop". @@ -569,7 +571,7 @@ void Thread::search() { } else if ( Threads.increaseDepth && !mainThread->ponder - && Time.elapsed() > Time.optimum() * fallingEval * reduction * bestMoveInstability * 0.6) + && Time.elapsed() > totalTime * 0.6) Threads.increaseDepth = false; else Threads.increaseDepth = true;