mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Refactor timeman.cpp
Move optExtra, optConstant and maxConstant into lower scope. closes https://github.com/official-stockfish/Stockfish/pull/5052 No functional change
This commit is contained in:
parent
5c03883107
commit
f4f0b32d55
2 changed files with 9 additions and 8 deletions
1
AUTHORS
1
AUTHORS
|
@ -216,6 +216,7 @@ Taras Vuk (TarasVuk)
|
||||||
Thanar2
|
Thanar2
|
||||||
thaspel
|
thaspel
|
||||||
theo77186
|
theo77186
|
||||||
|
TierynnB
|
||||||
Ting-Hsuan Huang (fffelix-huang)
|
Ting-Hsuan Huang (fffelix-huang)
|
||||||
Tobias Steinmann
|
Tobias Steinmann
|
||||||
Tomasz Sobczyk (Sopel97)
|
Tomasz Sobczyk (Sopel97)
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
namespace Stockfish {
|
namespace Stockfish {
|
||||||
|
|
||||||
|
|
||||||
TimePoint TimeManagement::optimum() const { return optimumTime; }
|
TimePoint TimeManagement::optimum() const { return optimumTime; }
|
||||||
TimePoint TimeManagement::maximum() const { return maximumTime; }
|
TimePoint TimeManagement::maximum() const { return maximumTime; }
|
||||||
TimePoint TimeManagement::elapsed(size_t nodes) const {
|
TimePoint TimeManagement::elapsed(size_t nodes) const {
|
||||||
|
@ -89,18 +88,19 @@ void TimeManagement::init(Search::LimitsType& limits,
|
||||||
TimePoint timeLeft = std::max(TimePoint(1), limits.time[us] + limits.inc[us] * (mtg - 1)
|
TimePoint timeLeft = std::max(TimePoint(1), limits.time[us] + limits.inc[us] * (mtg - 1)
|
||||||
- moveOverhead * (2 + mtg));
|
- moveOverhead * (2 + mtg));
|
||||||
|
|
||||||
// Use extra time with larger increments
|
|
||||||
double optExtra = std::clamp(1.0 + 12.5 * limits.inc[us] / limits.time[us], 1.0, 1.11);
|
|
||||||
|
|
||||||
// Calculate time constants based on current time left.
|
|
||||||
double optConstant = std::min(0.00334 + 0.0003 * std::log10(limits.time[us] / 1000.0), 0.0049);
|
|
||||||
double maxConstant = std::max(3.4 + 3.0 * std::log10(limits.time[us] / 1000.0), 2.76);
|
|
||||||
|
|
||||||
// x basetime (+ z increment)
|
// x basetime (+ z increment)
|
||||||
// If there is a healthy increment, timeLeft can exceed actual available
|
// If there is a healthy increment, timeLeft can exceed actual available
|
||||||
// game time for the current move, so also cap to 20% of available game time.
|
// game time for the current move, so also cap to 20% of available game time.
|
||||||
if (limits.movestogo == 0)
|
if (limits.movestogo == 0)
|
||||||
{
|
{
|
||||||
|
// Use extra time with larger increments
|
||||||
|
double optExtra = std::clamp(1.0 + 12.5 * limits.inc[us] / limits.time[us], 1.0, 1.11);
|
||||||
|
|
||||||
|
// Calculate time constants based on current time left.
|
||||||
|
double optConstant =
|
||||||
|
std::min(0.00334 + 0.0003 * std::log10(limits.time[us] / 1000.0), 0.0049);
|
||||||
|
double maxConstant = std::max(3.4 + 3.0 * std::log10(limits.time[us] / 1000.0), 2.76);
|
||||||
|
|
||||||
optScale = std::min(0.0120 + std::pow(ply + 3.1, 0.44) * optConstant,
|
optScale = std::min(0.0120 + std::pow(ply + 3.1, 0.44) * optConstant,
|
||||||
0.21 * limits.time[us] / double(timeLeft))
|
0.21 * limits.time[us] / double(timeLeft))
|
||||||
* optExtra;
|
* optExtra;
|
||||||
|
|
Loading…
Add table
Reference in a new issue