1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Time management simplification

10+0.1:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 41963 W: 7967 L: 7883 D: 26113

60+0.6:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 132314 W: 17939 L: 17969 D: 96406

Resolves #580
This commit is contained in:
Leonid Pechenik 2016-01-18 11:56:35 -05:00 committed by Joona Kiiski
parent 9a10313a9d
commit aedebe35cf
3 changed files with 4 additions and 10 deletions

View file

@ -544,10 +544,6 @@ void Thread::search() {
{ {
if (!Signals.stop && !Signals.stopOnPonderhit) if (!Signals.stop && !Signals.stopOnPonderhit)
{ {
// Take some extra time if the best move has changed
if (rootDepth > 4 * ONE_PLY && multiPV == 1)
Time.pv_instability(mainThread->bestMoveChanges);
// Stop the search if only one legal move is available, or if all // Stop the search if only one legal move is available, or if all
// of the available time has been used, or if we matched an easyMove // of the available time has been used, or if we matched an easyMove
// from the previous search and just did a fast verification. // from the previous search and just did a fast verification.
@ -555,13 +551,14 @@ void Thread::search() {
bestValue >= mainThread->previousScore }; bestValue >= mainThread->previousScore };
int improvingFactor = 640 - 160*F[0] - 126*F[1] - 124*F[0]*F[1]; int improvingFactor = 640 - 160*F[0] - 126*F[1] - 124*F[0]*F[1];
double unstablePvFactor = 1 + mainThread->bestMoveChanges;
bool doEasyMove = rootMoves[0].pv[0] == easyMove bool doEasyMove = rootMoves[0].pv[0] == easyMove
&& mainThread->bestMoveChanges < 0.03 && mainThread->bestMoveChanges < 0.03
&& Time.elapsed() > Time.available() * 25 / 206; && Time.elapsed() > Time.optimum() * 25 / 204;
if ( rootMoves.size() == 1 if ( rootMoves.size() == 1
|| Time.elapsed() > Time.available() * improvingFactor / 640 || Time.elapsed() > Time.optimum() * unstablePvFactor * improvingFactor / 634
|| (mainThread->easyMovePlayed = doEasyMove)) || (mainThread->easyMovePlayed = doEasyMove))
{ {
// If we are allowed to ponder do not stop the search now but // If we are allowed to ponder do not stop the search now but

View file

@ -104,7 +104,6 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply)
} }
startTime = limits.startTime; startTime = limits.startTime;
unstablePvFactor = 1;
optimumTime = maximumTime = std::max(limits.time[us], minThinkingTime); optimumTime = maximumTime = std::max(limits.time[us], minThinkingTime);
const int MaxMTG = limits.movestogo ? std::min(limits.movestogo, MoveHorizon) : MoveHorizon; const int MaxMTG = limits.movestogo ? std::min(limits.movestogo, MoveHorizon) : MoveHorizon;

View file

@ -31,8 +31,7 @@
class TimeManagement { class TimeManagement {
public: public:
void init(Search::LimitsType& limits, Color us, int ply); void init(Search::LimitsType& limits, Color us, int ply);
void pv_instability(double bestMoveChanges) { unstablePvFactor = 1 + bestMoveChanges; } int optimum() const { return optimumTime; }
int available() const { return int(optimumTime * unstablePvFactor * 1.01); }
int maximum() const { return maximumTime; } int maximum() const { return maximumTime; }
int elapsed() const { return int(Search::Limits.npmsec ? Threads.nodes_searched() : now() - startTime); } int elapsed() const { return int(Search::Limits.npmsec ? Threads.nodes_searched() : now() - startTime); }
@ -42,7 +41,6 @@ private:
TimePoint startTime; TimePoint startTime;
int optimumTime; int optimumTime;
int maximumTime; int maximumTime;
double unstablePvFactor;
}; };
extern TimeManagement Time; extern TimeManagement Time;