mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Collect more corrections to optimum/maximum
The only call site of Time.maximum() corrected by 10. Do this directly in remaining(). Ponder increased Time.optimum by 25% in init(). Idem. Delete unused includes. No functional change.
This commit is contained in:
parent
4d511512d2
commit
daf0fe1f57
2 changed files with 22 additions and 14 deletions
|
@ -1491,7 +1491,7 @@ moves_loop: // When in check search starts from here
|
||||||
if (Threads.ponder)
|
if (Threads.ponder)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( (Limits.use_time_management() && elapsed > Time.maximum() - 10)
|
if ( (Limits.use_time_management() && elapsed > Time.maximum())
|
||||||
|| (Limits.movetime && elapsed >= Limits.movetime)
|
|| (Limits.movetime && elapsed >= Limits.movetime)
|
||||||
|| (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes))
|
|| (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes))
|
||||||
Threads.stop = true;
|
Threads.stop = true;
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cfloat>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include "search.h"
|
#include "search.h"
|
||||||
#include "timeman.h"
|
#include "timeman.h"
|
||||||
|
@ -32,14 +30,14 @@ namespace {
|
||||||
|
|
||||||
enum TimeType { OptimumTime, MaxTime };
|
enum TimeType { OptimumTime, MaxTime };
|
||||||
|
|
||||||
int remaining(int myTime, int myInc, int moveOverhead,
|
int remaining(int myTime, int myInc, int moveOverhead, int movesToGo,
|
||||||
int movesToGo, int ply, TimeType type) {
|
int ply, bool ponder, TimeType type) {
|
||||||
|
|
||||||
if (myTime <= 0)
|
if (myTime <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int moveNumber = (ply + 1) / 2;
|
int moveNumber = (ply + 1) / 2;
|
||||||
double ratio; // Which ratio of myTime we are going to use. It is <= 1
|
double ratio; // Which ratio of myTime we are going to use. It's <= 1 if not ponder
|
||||||
double sd = 8.5;
|
double sd = 8.5;
|
||||||
|
|
||||||
// Usage of increment follows quadratic distribution with the maximum at move 25
|
// Usage of increment follows quadratic distribution with the maximum at move 25
|
||||||
|
@ -65,7 +63,17 @@ namespace {
|
||||||
|
|
||||||
ratio = std::min(1.0, ratio * (1 + inc / (myTime * sd)));
|
ratio = std::min(1.0, ratio * (1 + inc / (myTime * sd)));
|
||||||
|
|
||||||
return int(ratio * std::max(0, myTime - moveOverhead));
|
assert(ratio <= 1);
|
||||||
|
|
||||||
|
if (ponder && type == OptimumTime)
|
||||||
|
ratio *= 1.25;
|
||||||
|
|
||||||
|
int time = int(ratio * (myTime - moveOverhead));
|
||||||
|
|
||||||
|
if (type == OptimumTime)
|
||||||
|
time -= 10; // Keep always at least 10 millisecs on the clock
|
||||||
|
|
||||||
|
return std::max(0, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -82,8 +90,9 @@ namespace {
|
||||||
|
|
||||||
void TimeManagement::init(Search::LimitsType& limits, Color us, int ply)
|
void TimeManagement::init(Search::LimitsType& limits, Color us, int ply)
|
||||||
{
|
{
|
||||||
int moveOverhead = Options["Move Overhead"];
|
int moveOverhead = Options["Move Overhead"];
|
||||||
int npmsec = Options["nodestime"];
|
int npmsec = Options["nodestime"];
|
||||||
|
bool ponder = Options["Ponder"];
|
||||||
|
|
||||||
// If we have to play in 'nodes as time' mode, then convert from time
|
// If we have to play in 'nodes as time' mode, then convert from time
|
||||||
// to nodes, and use resulting values in time management formulas.
|
// to nodes, and use resulting values in time management formulas.
|
||||||
|
@ -101,9 +110,8 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply)
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = limits.startTime;
|
startTime = limits.startTime;
|
||||||
optimumTime = remaining(limits.time[us], limits.inc[us], moveOverhead, limits.movestogo, ply, OptimumTime);
|
optimumTime = remaining(limits.time[us], limits.inc[us], moveOverhead,
|
||||||
maximumTime = remaining(limits.time[us], limits.inc[us], moveOverhead, limits.movestogo, ply, MaxTime);
|
limits.movestogo, ply, ponder, OptimumTime);
|
||||||
|
maximumTime = remaining(limits.time[us], limits.inc[us], moveOverhead,
|
||||||
if (Options["Ponder"])
|
limits.movestogo, ply, ponder, MaxTime);
|
||||||
optimumTime += optimumTime / 4;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue