Consider board size in time management
authorFabian Fichter <ianfab@users.noreply.github.com>
Tue, 1 Jan 2019 15:50:11 +0000 (16:50 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Tue, 1 Jan 2019 15:50:11 +0000 (16:50 +0100)
Also adjust for variants with mandatory captures.

courier 5+0
LLR: 2.97 (-2.94,2.94) [0.00,10.00]
Total: 302 W: 161 L: 74 D: 67

shogi 5+0
LLR: 2.98 (-2.94,2.94) [0.00,10.00]
Total: 1064 W: 570 L: 455 D: 39

minishogi 5+0
LLR: 2.99 (-2.94,2.94) [0.00,10.00]
Total: 1362 W: 702 L: 584 D: 76

giveaway 10+0
LLR: 2.97 (-2.94,2.94) [0.00,10.00]
Total: 1019 W: 437 L: 340 D: 242
http://35.161.250.236:6543/tests/view/5c2a423f6e23db2472895682

giveaway 10+0.1
LLR: 2.95 (-2.94,2.94) [0.00,10.00]
Total: 1655 W: 691 L: 585 D: 379
http://35.161.250.236:6543/tests/view/5c2a41a46e23db247289567b

losers 10+0
LLR: 2.94 (-2.94,2.94) [0.00,10.00]
Total: 1030 W: 520 L: 412 D: 98
http://35.161.250.236:6543/tests/view/5c2a42356e23db2472895680

losers 10+0.1
LLR: 2.96 (-2.94,2.94) [0.00,10.00]
Total: 1004 W: 496 L: 390 D: 118
http://35.161.250.236:6543/tests/view/5c2a41cd6e23db247289567e

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

index 1cf1720..5411834 100644 (file)
@@ -196,7 +196,7 @@ void MainThread::search() {
   }
 
   Color us = rootPos.side_to_move();
-  Time.init(Limits, us, rootPos.game_ply());
+  Time.init(rootPos, Limits, us, rootPos.game_ply());
   TT.new_search();
 
   if (rootMoves.empty())
index ade25c4..ec1c47f 100644 (file)
@@ -42,26 +42,26 @@ namespace {
   // is considered "undecided" as long as neither side has >275cp advantage.
   // Data was extracted from the CCRL game database with some simple filtering criteria.
 
-  double move_importance(int ply) {
+  double move_importance(const Position& pos, int ply) {
 
     constexpr double XScale = 6.85;
-    constexpr double XShift = 64.5;
+    double XShift = (pos.max_rank() + 1) * (pos.max_file() + 1) / (1 + pos.must_capture()) + 0.5;
     constexpr double Skew   = 0.171;
 
     return pow((1 + exp((ply - XShift) / XScale)), -Skew) + DBL_MIN; // Ensure non-zero
   }
 
   template<TimeType T>
-  TimePoint remaining(TimePoint myTime, int movesToGo, int ply, TimePoint slowMover) {
+  TimePoint remaining(const Position& pos, TimePoint myTime, int movesToGo, int ply, TimePoint slowMover) {
 
     constexpr double TMaxRatio   = (T == OptimumTime ? 1.0 : MaxRatio);
     constexpr double TStealRatio = (T == OptimumTime ? 0.0 : StealRatio);
 
-    double moveImportance = (move_importance(ply) * slowMover) / 100.0;
+    double moveImportance = (move_importance(pos, ply) * slowMover) / 100.0;
     double otherMovesImportance = 0.0;
 
     for (int i = 1; i < movesToGo; ++i)
-        otherMovesImportance += move_importance(ply + 2 * i);
+        otherMovesImportance += move_importance(pos, ply + 2 * i);
 
     double ratio1 = (TMaxRatio * moveImportance) / (TMaxRatio * moveImportance + otherMovesImportance);
     double ratio2 = (moveImportance + TStealRatio * otherMovesImportance) / (moveImportance + otherMovesImportance);
@@ -81,7 +81,7 @@ namespace {
 ///  inc >  0 && movestogo == 0 means: x basetime + z increment
 ///  inc >  0 && movestogo != 0 means: x moves in y minutes + z increment
 
-void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
+void TimeManagement::init(const Position& pos, Search::LimitsType& limits, Color us, int ply) {
 
   TimePoint minThinkingTime = Options["Minimum Thinking Time"];
   TimePoint moveOverhead    = Options["Move Overhead"];
@@ -121,8 +121,8 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
 
       hypMyTime = std::max(hypMyTime, TimePoint(0));
 
-      TimePoint t1 = minThinkingTime + remaining<OptimumTime>(hypMyTime, hypMTG, ply, slowMover);
-      TimePoint t2 = minThinkingTime + remaining<MaxTime    >(hypMyTime, hypMTG, ply, slowMover);
+      TimePoint t1 = minThinkingTime + remaining<OptimumTime>(pos, hypMyTime, hypMTG, ply, slowMover);
+      TimePoint t2 = minThinkingTime + remaining<MaxTime    >(pos, hypMyTime, hypMTG, ply, slowMover);
 
       optimumTime = std::min(t1, optimumTime);
       maximumTime = std::min(t2, maximumTime);
index fad898e..82e832c 100644 (file)
@@ -30,7 +30,7 @@
 
 class TimeManagement {
 public:
-  void init(Search::LimitsType& limits, Color us, int ply);
+  void init(const Position& pos, Search::LimitsType& limits, Color us, int ply);
   TimePoint optimum() const { return optimumTime; }
   TimePoint maximum() const { return maximumTime; }
   TimePoint elapsed() const { return Search::Limits.npmsec ?