From: Leonid Pechenik Date: Tue, 11 Feb 2014 09:01:06 +0000 (-0500) Subject: Simplify time management X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=72e8640f4d98be6aefcf3d486e608da21ac44b2d Simplify time management Tested with simplification mode SPRT[-4, 0] Passed both short TC LLR: 2.95 (-2.94,2.94) [-4.00,0.00] Total: 34102 W: 6184 L: 6144 D: 21774 And long TC LLR: 2.96 (-2.94,2.94) [-4.00,0.00] Total: 16518 W: 2647 L: 2545 D: 11326 And also 40/10 TC LLR: 2.95 (-2.94,2.94) [-4.00,0.00] Total: 22406 W: 4390 L: 4312 D: 13704 bench: 8430785 --- diff --git a/src/search.cpp b/src/search.cpp index 7188925c..0cd49085 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -320,7 +320,7 @@ namespace { while (++depth <= MAX_PLY && !Signals.stop && (!Limits.depth || depth <= Limits.depth)) { // Age out PV variability metric - BestMoveChanges *= 0.8; + BestMoveChanges *= 0.5; // Save the last iteration's scores before first PV line is searched and // all the move scores except the (new) PV are set to -VALUE_INFINITE. @@ -429,11 +429,10 @@ namespace { if (depth > 4 && depth < 50 && PVSize == 1) TimeMgr.pv_instability(BestMoveChanges); - // 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. + // Stop the search if only one legal move is available or all + // of the available time has been used. if ( RootMoves.size() == 1 - || IterationTime > (TimeMgr.available_time() * 62) / 100) + || IterationTime > TimeMgr.available_time() ) stop = true; if (stop) @@ -1628,9 +1627,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)); + && elapsed > TimeMgr.available_time() + && elapsed > IterationTime * 1.4; bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerThread::Resolution || stillAtFirstMove; diff --git a/src/timeman.cpp b/src/timeman.cpp index 702f0f31..051d9726 100644 --- a/src/timeman.cpp +++ b/src/timeman.cpp @@ -60,7 +60,7 @@ namespace { void TimeManager::pv_instability(double bestMoveChanges) { - unstablePVExtraTime = int(bestMoveChanges * optimumSearchTime / 1.4); + unstablePvFactor = 1 + bestMoveChanges; } @@ -90,8 +90,8 @@ void TimeManager::init(const Search::LimitsType& limits, int currentPly, Color u int minThinkingTime = Options["Minimum Thinking Time"]; int slowMover = Options["Slow Mover"]; - // Initialize all to maximum values but unstablePVExtraTime that is reset - unstablePVExtraTime = 0; + // Initialize unstablePvFactor to 1 and search times to maximum values + unstablePvFactor = 1; optimumSearchTime = maximumSearchTime = std::max(limits.time[us], minThinkingTime); // We calculate optimum time usage for different hypothetical "moves to go"-values and choose the diff --git a/src/timeman.h b/src/timeman.h index 6ac9f360..5a98f614 100644 --- a/src/timeman.h +++ b/src/timeman.h @@ -27,13 +27,13 @@ class TimeManager { public: void init(const Search::LimitsType& limits, int currentPly, Color us); void pv_instability(double bestMoveChanges); - int available_time() const { return optimumSearchTime + unstablePVExtraTime; } + int available_time() const { return int(optimumSearchTime * unstablePvFactor * 0.62); } int maximum_time() const { return maximumSearchTime; } private: int optimumSearchTime; int maximumSearchTime; - int unstablePVExtraTime; + double unstablePvFactor; }; #endif // #ifndef TIMEMAN_H_INCLUDED diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 22a335f5..c96c1d7b 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -83,7 +83,7 @@ void init(OptionsMap& o) { o["Emergency Base Time"] = Option(60, 0, 30000); o["Emergency Move Time"] = Option(30, 0, 5000); o["Minimum Thinking Time"] = Option(20, 0, 5000); - o["Slow Mover"] = Option(70, 10, 1000); + o["Slow Mover"] = Option(80, 10, 1000); o["UCI_Chess960"] = Option(false); o["UCI_AnalyseMode"] = Option(false, on_eval); }