Skip to content

Commit 5cf3f49

Browse files
committed
use current time instead of '1' for timeLeft
formula. make timeLeft a double, timepoint seemed unecessary since it was always casting back to double anyway.
1 parent bf2c730 commit 5cf3f49

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/timeman.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ void TimeManagement::init(Search::LimitsType& limits,
8181
limits.npmsec = npmsec;
8282
}
8383

84-
// Maximum move horizon of 50 moves
84+
// Maximum and default move horizon of 50 moves
8585
int mtg = limits.movestogo ? std::min(limits.movestogo, 50) : 50;
8686

87-
// Make sure timeLeft is > 0 since we may use it as a divisor
88-
TimePoint timeLeft = std::max(TimePoint(1), limits.time[us] + limits.inc[us] * (mtg - 1)
89-
- moveOverhead * (2 + mtg));
87+
// Make sure timeLeft is > 0 since we use it as a divisor
88+
double timeLeft =
89+
std::max(limits.time[us], limits.time[us] + limits.inc[us] * (mtg - 1) - moveOverhead * mtg);
9090

9191
// x basetime (+ z increment)
92-
// If there is a healthy increment, timeLeft can exceed actual available
92+
// If there is a healthy increment and low mtg, timeLeft can exceed actual available
9393
// game time for the current move, so also cap to 20% of available game time.
9494
if (limits.movestogo == 0)
9595
{
@@ -102,15 +102,15 @@ void TimeManagement::init(Search::LimitsType& limits,
102102
double maxConstant = std::max(3.4 + 3.0 * std::log10(limits.time[us] / 1000.0), 2.76);
103103

104104
optScale = std::min(0.0120 + std::pow(ply + 3.1, 0.44) * optConstant,
105-
0.21 * limits.time[us] / double(timeLeft))
105+
0.21 * limits.time[us] / timeLeft)
106106
* optExtra;
107107
maxScale = std::min(6.9, maxConstant + ply / 12.2);
108108
}
109109

110110
// x moves in y seconds (+ z increment)
111111
else
112112
{
113-
optScale = std::min((0.88 + ply / 116.4) / mtg, 0.88 * limits.time[us] / double(timeLeft));
113+
optScale = std::min((0.88 + ply / 116.4) / mtg, 0.88 * limits.time[us] / timeLeft);
114114
maxScale = std::min(6.3, 1.5 + 0.11 * mtg);
115115
}
116116

0 commit comments

Comments
 (0)