Skip to content

Commit

Permalink
Add "Minimal" option where only info from the final search depth is p…
Browse files Browse the repository at this point in the history
…rinted (#760)

Done due to CuteChess being too slow to parse the normal output.

Bench: 24311257
  • Loading branch information
TerjeKir authored Dec 29, 2024
1 parent 2a3f84c commit 179c96b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
SearchLimits Limits = { .multiPV = 1 };
atomic_bool ABORT_SIGNAL;
atomic_bool SEARCH_STOPPED = true;
atomic_bool Minimal = false;

static int Reductions[2][32][32];

Expand Down Expand Up @@ -687,6 +688,7 @@ static void AspirationWindow(Thread *thread, Stack *ss) {
// Give an update when failing high/low in longer searches
if ( mainThread
&& Limits.multiPV == 1
&& !Minimal
&& (score <= alpha || score >= beta)
&& TimeSince(Limits.start) > 3000)
PrintThinking(thread, alpha, beta);
Expand Down Expand Up @@ -739,8 +741,9 @@ static void *IterativeDeepening(void *voidThread) {
// Only the main thread concerns itself with the rest
if (!mainThread) continue;

// Print thinking info
PrintThinking(thread, -INFINITE, INFINITE);
// Print search info
if (!Minimal)
PrintThinking(thread, -INFINITE, INFINITE);

// Stop searching after finding a short enough mate
if (MATE - abs(thread->rootMoves[0].score) <= 2 * abs(Limits.mate)) break;
Expand All @@ -763,6 +766,14 @@ static void *IterativeDeepening(void *voidThread) {
history(i).key = 0;
}

// Print final search info in minimal mode
if (mainThread && Minimal) {
// Fix the depth when the search is stopped due to reaching the depth limit
if (thread->depth > Limits.depth)
thread->depth--;
PrintThinking(thread, -INFINITE, INFINITE);
}

return NULL;
}

Expand Down
1 change: 1 addition & 0 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef struct {
extern SearchLimits Limits;
extern atomic_bool ABORT_SIGNAL;
extern atomic_bool SEARCH_STOPPED;
extern atomic_bool Minimal;


void *SearchPosition(void *pos);
2 changes: 2 additions & 0 deletions src/uci.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static void SetOption(char *str) {
else if (OptionNameIs("Threads" )) InitThreads(IntValue);
else if (OptionNameIs("SyzygyPath" )) tb_init(optionValue);
else if (OptionNameIs("MultiPV" )) Limits.multiPV = IntValue;
else if (OptionNameIs("Minimal" )) Minimal = BooleanValue;
else if (OptionNameIs("NoobBookLimit")) NoobLimit = IntValue;
else if (OptionNameIs("NoobBookMode" )) NoobBookSetMode(optionValue);
else if (OptionNameIs("NoobBook" )) NoobBook = BooleanValue;
Expand All @@ -133,6 +134,7 @@ static void Info() {
printf("option name Threads type spin default %d min %d max %d\n", 1, 1, 2048);
printf("option name SyzygyPath type string default <empty>\n");
printf("option name MultiPV type spin default 1 min 1 max %d\n", MULTI_PV_MAX);
printf("option name Minimal type check default false\n");
printf("option name UCI_Chess960 type check default false\n");
printf("option name NoobBook type check default false\n");
printf("option name NoobBookMode type string default <best>\n");
Expand Down

0 comments on commit 179c96b

Please sign in to comment.