- // Read uci parameters
- int emergencyMoveHorizon = Options["Emergency Move Horizon"];
- int emergencyBaseTime = Options["Emergency Base Time"];
- int emergencyMoveTime = Options["Emergency Move Time"];
- int minThinkingTime = Options["Minimum Thinking Time"];
- int slowMover = Options["Slow Mover"];
-
- // 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
- // minimum of calculated search time values. Usually the greatest hypMTG gives the minimum values.
- for (hypMTG = 1; hypMTG <= (limits.movestogo ? std::min(limits.movestogo, MoveHorizon) : MoveHorizon); ++hypMTG)
- {
- // Calculate thinking time for hypothetical "moves to go"-value
- hypMyTime = limits.time[us]
- + limits.inc[us] * (hypMTG - 1)
- - emergencyBaseTime
- - emergencyMoveTime * std::min(hypMTG, emergencyMoveHorizon);
-
- hypMyTime = std::max(hypMyTime, 0);
-
- t1 = minThinkingTime + remaining<OptimumTime>(hypMyTime, hypMTG, currentPly, slowMover);
- t2 = minThinkingTime + remaining<MaxTime>(hypMyTime, hypMTG, currentPly, slowMover);
-
- optimumSearchTime = std::min(optimumSearchTime, t1);
- maximumSearchTime = std::min(maximumSearchTime, t2);