1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 01:03:09 +00:00

Simplify time management

Tested with simplification mode SPRT[-4, 0]

Passed both short TC
LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 34102 W: 6184 L: 6144 D: 21774

And long TC
LLR: 2.96 (-2.94,2.94) [-4.00,0.00]
Total: 16518 W: 2647 L: 2545 D: 11326

And also 40/10 TC
LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 22406 W: 4390 L: 4312 D: 13704

bench: 8430785
This commit is contained in:
Leonid Pechenik 2014-02-11 04:01:06 -05:00 committed by Marco Costalba
parent e6523e56b8
commit 72e8640f4d
4 changed files with 12 additions and 14 deletions

View file

@ -320,7 +320,7 @@ namespace {
while (++depth <= MAX_PLY && !Signals.stop && (!Limits.depth || depth <= Limits.depth)) while (++depth <= MAX_PLY && !Signals.stop && (!Limits.depth || depth <= Limits.depth))
{ {
// Age out PV variability metric // Age out PV variability metric
BestMoveChanges *= 0.8; BestMoveChanges *= 0.5;
// Save the last iteration's scores before first PV line is searched and // Save the last iteration's scores before first PV line is searched and
// all the move scores except the (new) PV are set to -VALUE_INFINITE. // all the move scores except the (new) PV are set to -VALUE_INFINITE.
@ -429,11 +429,10 @@ namespace {
if (depth > 4 && depth < 50 && PVSize == 1) if (depth > 4 && depth < 50 && PVSize == 1)
TimeMgr.pv_instability(BestMoveChanges); TimeMgr.pv_instability(BestMoveChanges);
// Stop the search if only one legal move is available or most // Stop the search if only one legal move is available or all
// of the available time has been used. We probably don't have // of the available time has been used.
// enough time to search the first move at the next iteration anyway.
if ( RootMoves.size() == 1 if ( RootMoves.size() == 1
|| IterationTime > (TimeMgr.available_time() * 62) / 100) || IterationTime > TimeMgr.available_time() )
stop = true; stop = true;
if (stop) if (stop)
@ -1628,9 +1627,8 @@ void check_time() {
Time::point elapsed = Time::now() - SearchTime; Time::point elapsed = Time::now() - SearchTime;
bool stillAtFirstMove = Signals.firstRootMove bool stillAtFirstMove = Signals.firstRootMove
&& !Signals.failedLowAtRoot && !Signals.failedLowAtRoot
&& ( elapsed > TimeMgr.available_time() && elapsed > TimeMgr.available_time()
|| ( elapsed > (TimeMgr.available_time() * 62) / 100 && elapsed > IterationTime * 1.4;
&& elapsed > IterationTime * 1.4));
bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerThread::Resolution bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerThread::Resolution
|| stillAtFirstMove; || stillAtFirstMove;

View file

@ -60,7 +60,7 @@ namespace {
void TimeManager::pv_instability(double bestMoveChanges) { void TimeManager::pv_instability(double bestMoveChanges) {
unstablePVExtraTime = int(bestMoveChanges * optimumSearchTime / 1.4); unstablePvFactor = 1 + bestMoveChanges;
} }
@ -90,8 +90,8 @@ void TimeManager::init(const Search::LimitsType& limits, int currentPly, Color u
int minThinkingTime = Options["Minimum Thinking Time"]; int minThinkingTime = Options["Minimum Thinking Time"];
int slowMover = Options["Slow Mover"]; int slowMover = Options["Slow Mover"];
// Initialize all to maximum values but unstablePVExtraTime that is reset // Initialize unstablePvFactor to 1 and search times to maximum values
unstablePVExtraTime = 0; unstablePvFactor = 1;
optimumSearchTime = maximumSearchTime = std::max(limits.time[us], minThinkingTime); optimumSearchTime = maximumSearchTime = std::max(limits.time[us], minThinkingTime);
// We calculate optimum time usage for different hypothetical "moves to go"-values and choose the // We calculate optimum time usage for different hypothetical "moves to go"-values and choose the

View file

@ -27,13 +27,13 @@ class TimeManager {
public: public:
void init(const Search::LimitsType& limits, int currentPly, Color us); void init(const Search::LimitsType& limits, int currentPly, Color us);
void pv_instability(double bestMoveChanges); void pv_instability(double bestMoveChanges);
int available_time() const { return optimumSearchTime + unstablePVExtraTime; } int available_time() const { return int(optimumSearchTime * unstablePvFactor * 0.62); }
int maximum_time() const { return maximumSearchTime; } int maximum_time() const { return maximumSearchTime; }
private: private:
int optimumSearchTime; int optimumSearchTime;
int maximumSearchTime; int maximumSearchTime;
int unstablePVExtraTime; double unstablePvFactor;
}; };
#endif // #ifndef TIMEMAN_H_INCLUDED #endif // #ifndef TIMEMAN_H_INCLUDED

View file

@ -83,7 +83,7 @@ void init(OptionsMap& o) {
o["Emergency Base Time"] = Option(60, 0, 30000); o["Emergency Base Time"] = Option(60, 0, 30000);
o["Emergency Move Time"] = Option(30, 0, 5000); o["Emergency Move Time"] = Option(30, 0, 5000);
o["Minimum Thinking Time"] = Option(20, 0, 5000); o["Minimum Thinking Time"] = Option(20, 0, 5000);
o["Slow Mover"] = Option(70, 10, 1000); o["Slow Mover"] = Option(80, 10, 1000);
o["UCI_Chess960"] = Option(false); o["UCI_Chess960"] = Option(false);
o["UCI_AnalyseMode"] = Option(false, on_eval); o["UCI_AnalyseMode"] = Option(false, on_eval);
} }