Skip to content

Commit

Permalink
Bench: 22158564
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Nov 15, 2024
1 parent 5b0524d commit ad059d9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ static void AspirationWindow(Thread *thread, Stack *ss) {
thread->doPruning =
Limits.infinite ? TimeSince(Limits.start) > 1000
: TimeSince(Limits.start) >= Limits.optimalUsage / 64
|| depth > 2 + Limits.optimalUsage / 270;
|| depth > 2 + Limits.optimalUsage / 270
|| Limits.nodeTime;

int score = AlphaBeta(thread, ss, alpha, beta, depth, false);

Expand Down
3 changes: 2 additions & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
typedef struct {
TimePoint start;
int time, inc, movestogo, movetime, depth;
uint64_t nodes;
int optimalUsage, maxUsage;
int mate;
bool timelimit, infinite;
bool timelimit, nodeTime, infinite;
Move searchmoves[64];
int multiPV;
} SearchLimits;
Expand Down
18 changes: 12 additions & 6 deletions src/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,21 @@ void InitTimeManagement() {
// Check time situation
bool OutOfTime(Thread *thread) {
if ( thread->index != 0
|| thread->depth == 1
|| (thread->pos.nodes & 2047) != 2047)
|| thread->depth == 1)
return false;

if (Limits.nodeTime && thread->pos.nodes >= Limits.nodes)
return true;

if ((thread->pos.nodes & 2047) != 2047)
return false;

int elapsed = TimeSince(Limits.start);

if ( !thread->doPruning
&& Limits.infinite ? TimeSince(Limits.start) > 5000
: TimeSince(Limits.start) >= Limits.optimalUsage / 32)
&& Limits.infinite ? elapsed > 5000
: elapsed >= Limits.optimalUsage / 32)
thread->doPruning = true;

return Limits.timelimit
&& TimeSince(Limits.start) >= Limits.maxUsage;
return Limits.timelimit && elapsed >= Limits.maxUsage;
}
2 changes: 2 additions & 0 deletions src/uci.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static void ParseTimeControl(const char *str, const Position *pos) {
SetLimit(str, "movestogo", &Limits.movestogo);
SetLimit(str, "movetime", &Limits.movetime);
SetLimit(str, "depth", &Limits.depth);
SetLimit(str, "nodes", (int *)&Limits.nodes);
SetLimit(str, "mate", &Limits.mate);

// Parse searchmoves, assumes they are at the end of the string
Expand All @@ -58,6 +59,7 @@ static void ParseTimeControl(const char *str, const Position *pos) {
}

Limits.timelimit = Limits.time || Limits.movetime;
Limits.nodeTime = Limits.nodes;
Limits.depth = Limits.depth ?: 100;
}

Expand Down

0 comments on commit ad059d9

Please sign in to comment.