]> git.sesse.net Git - stockfish/commitdiff
Time management simplification
authorLeonid Pechenik <lp@home>
Mon, 18 Jan 2016 16:56:35 +0000 (11:56 -0500)
committerJoona Kiiski <joona@zoox.com>
Fri, 29 Jan 2016 00:47:07 +0000 (00:47 +0000)
10+0.1:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 41963 W: 7967 L: 7883 D: 26113

60+0.6:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 132314 W: 17939 L: 17969 D: 96406

Resolves #580

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

index 61d0c4b2aaaadc36880ba5e59bcd00a8c58358dc..763a6ac31194a8ae8b8a6e92bbbf0700894373a7 100644 (file)
@@ -544,10 +544,6 @@ void Thread::search() {
       {
           if (!Signals.stop && !Signals.stopOnPonderhit)
           {
       {
           if (!Signals.stop && !Signals.stopOnPonderhit)
           {
-              // Take some extra time if the best move has changed
-              if (rootDepth > 4 * ONE_PLY && multiPV == 1)
-                  Time.pv_instability(mainThread->bestMoveChanges);
-
               // Stop the search if only one legal move is available, or if all
               // of the available time has been used, or if we matched an easyMove
               // from the previous search and just did a fast verification.
               // Stop the search if only one legal move is available, or if all
               // of the available time has been used, or if we matched an easyMove
               // from the previous search and just did a fast verification.
@@ -555,13 +551,14 @@ void Thread::search() {
                                  bestValue >= mainThread->previousScore };
 
               int improvingFactor = 640 - 160*F[0] - 126*F[1] - 124*F[0]*F[1];
                                  bestValue >= mainThread->previousScore };
 
               int improvingFactor = 640 - 160*F[0] - 126*F[1] - 124*F[0]*F[1];
+              double unstablePvFactor = 1 + mainThread->bestMoveChanges;
 
               bool doEasyMove =   rootMoves[0].pv[0] == easyMove
                                && mainThread->bestMoveChanges < 0.03
 
               bool doEasyMove =   rootMoves[0].pv[0] == easyMove
                                && mainThread->bestMoveChanges < 0.03
-                               && Time.elapsed() > Time.available() * 25 / 206;
+                               && Time.elapsed() > Time.optimum() * 25 / 204;
 
               if (   rootMoves.size() == 1
 
               if (   rootMoves.size() == 1
-                  || Time.elapsed() > Time.available() * improvingFactor / 640
+                  || Time.elapsed() > Time.optimum() * unstablePvFactor * improvingFactor / 634
                   || (mainThread->easyMovePlayed = doEasyMove))
               {
                   // If we are allowed to ponder do not stop the search now but
                   || (mainThread->easyMovePlayed = doEasyMove))
               {
                   // If we are allowed to ponder do not stop the search now but
index 0bc9c159bbe2f3a5175e1423d2ba2cc6a1e6e7e2..bc9c2e5b4b7876025d9cf86126cdeec4f242a633 100644 (file)
@@ -104,7 +104,6 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply)
   }
 
   startTime = limits.startTime;
   }
 
   startTime = limits.startTime;
-  unstablePvFactor = 1;
   optimumTime = maximumTime = std::max(limits.time[us], minThinkingTime);
 
   const int MaxMTG = limits.movestogo ? std::min(limits.movestogo, MoveHorizon) : MoveHorizon;
   optimumTime = maximumTime = std::max(limits.time[us], minThinkingTime);
 
   const int MaxMTG = limits.movestogo ? std::min(limits.movestogo, MoveHorizon) : MoveHorizon;
index 0da083dc6bd9b8c68ebee2cfa25c7521bfbaa380..9930a4b719042dd6cc9bf270988a92da0a728cdf 100644 (file)
@@ -31,8 +31,7 @@
 class TimeManagement {
 public:
   void init(Search::LimitsType& limits, Color us, int ply);
 class TimeManagement {
 public:
   void init(Search::LimitsType& limits, Color us, int ply);
-  void pv_instability(double bestMoveChanges) { unstablePvFactor = 1 + bestMoveChanges; }
-  int available() const { return int(optimumTime * unstablePvFactor * 1.01); }
+  int optimum() const { return optimumTime; }
   int maximum() const { return maximumTime; }
   int elapsed() const { return int(Search::Limits.npmsec ? Threads.nodes_searched() : now() - startTime); }
 
   int maximum() const { return maximumTime; }
   int elapsed() const { return int(Search::Limits.npmsec ? Threads.nodes_searched() : now() - startTime); }
 
@@ -42,7 +41,6 @@ private:
   TimePoint startTime;
   int optimumTime;
   int maximumTime;
   TimePoint startTime;
   int optimumTime;
   int maximumTime;
-  double unstablePvFactor;
 };
 
 extern TimeManagement Time;
 };
 
 extern TimeManagement Time;