]> git.sesse.net Git - stockfish/commitdiff
Simplify time management
authorLeonid Pechenik <lp@home>
Tue, 11 Feb 2014 09:01:06 +0000 (04:01 -0500)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 12 Feb 2014 19:01:11 +0000 (20:01 +0100)
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

src/search.cpp
src/timeman.cpp
src/timeman.h
src/ucioption.cpp

index 7188925c0e73c2f3e2fae8d5e2c1b77e5dea2374..0cd490850cdbe57007053b4ed59bdc87131ddd72 100644 (file)
@@ -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;
index 702f0f31eafb8f7d751552078bf12b18a889e6f9..051d9726aa9ae29cb6398d00d79db23b090653bc 100644 (file)
@@ -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
index 6ac9f36008769a9422b0301b1fd432dada398aac..5a98f614f2318f580c5a3b0bdc8a6f15c94fa13c 100644 (file)
@@ -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
index 22a335f5883e519ddb095d4e247cf0a701d03005..c96c1d7ba51c8522c91a45871655e2f34e1e3bb3 100644 (file)
@@ -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);
 }