X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=505e9ec2a481f49efa53e3276c14e2c6b15b1572;hp=7075c3373a2c90eec8a021e45d8552544f529ab7;hb=a5869d8d2532c6bb8dbcba7d74331c0ac0230482;hpb=45dbd9cd0303d0db469670af8ec3598731a4eace diff --git a/src/search.cpp b/src/search.cpp index 7075c337..505e9ec2 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -43,7 +43,7 @@ namespace Search { std::vector RootMoves; Position RootPos; Color RootColor; - Time::point SearchTime; + Time::point SearchTime, IterationTime; StateStackPtr SetupStates; } @@ -396,6 +396,8 @@ namespace { sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; } + IterationTime = Time::now() - SearchTime; + // If skill levels are enabled and time is up, pick a sub-optimal best move if (skill.enabled() && skill.time_to_pick(depth)) skill.pick_move(); @@ -429,7 +431,7 @@ namespace { // Stop the search if most of the available time has been used. We // probably don't have enough time to search the first move at the // next iteration anyway. - if (Time::now() - SearchTime > (TimeMgr.available_time() * 62) / 100) + if (IterationTime > (TimeMgr.available_time() * 62) / 100) stop = true; // Stop the search early if one move seems to be much better than others @@ -1629,7 +1631,8 @@ void check_time() { Time::point elapsed = Time::now() - SearchTime; bool stillAtFirstMove = Signals.firstRootMove && !Signals.failedLowAtRoot - && elapsed > TimeMgr.available_time(); + && elapsed > (TimeMgr.available_time() * 62) / 100 + && elapsed > IterationTime * 1.4; bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerThread::Resolution || stillAtFirstMove;