Skip to content

Commit

Permalink
When below 1 second, reduce mtg if above a reasonable threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
TierynnB committed Mar 10, 2024
1 parent 632f1c2 commit 9d08232
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/timeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ void TimeManagement::init(Search::LimitsType& limits,
// Maximum move horizon of 50 moves
int mtg = limits.movestogo ? std::min(limits.movestogo, 50) : 50;

// if less than one second, gradually reduce mtg
if (limits.time[us] < 1000 && (double(mtg) / limits.time[us] > 0.05))
{
mtg = limits.time[us] * 0.05;
}

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

0 comments on commit 9d08232

Please sign in to comment.