X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=be82568a2179f03eb9bce512617950a7abad8f50;hp=7075c3373a2c90eec8a021e45d8552544f529ab7;hb=f14cd1bb89d080f36a11df3c90f15da881c599df;hpb=0118623495e2ef8a29cbe6ac76609521417490d2 diff --git a/src/search.cpp b/src/search.cpp index 7075c337..be82568a 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(); @@ -426,32 +428,13 @@ namespace { if (depth > 4 && depth < 50 && PVSize == 1) TimeMgr.pv_instability(BestMoveChanges); - // 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) + // Stop the search if only one legal move is available or 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 ( RootMoves.size() == 1 + || IterationTime > (TimeMgr.available_time() * 62) / 100) stop = true; - // Stop the search early if one move seems to be much better than others - if ( depth >= 12 - && BestMoveChanges <= DBL_EPSILON - && !stop - && PVSize == 1 - && bestValue > VALUE_MATED_IN_MAX_PLY - && ( RootMoves.size() == 1 - || Time::now() - SearchTime > (TimeMgr.available_time() * 20) / 100)) - { - Value rBeta = bestValue - 2 * PawnValueMg; - ss->excludedMove = RootMoves[0].pv[0]; - ss->skipNullMove = true; - Value v = search(pos, ss, rBeta - 1, rBeta, (depth - 3) * ONE_PLY, true); - ss->skipNullMove = false; - ss->excludedMove = MOVE_NONE; - - if (v < rBeta) - stop = true; - } - if (stop) { // If we are allowed to ponder do not stop the search now but @@ -1629,7 +1612,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;