feat: coloured search output for a terminal

Started from a terminal, Rigby now shows its search for a human:
coloured progress lines (depth/seldepth, playouts, speed, time, a tree
fill bar, score in pawns, the PV fading with depth) at 125, 250, 500 ms
and then every second, and at the end a table of the most visited root
moves with a bar for their share of the visits, their score and prior.
Tree reuse and collections are shown as notes, and bestmove is
highlighted.

The first "uci" command switches to plain UCI output for good. GUIs and
match runners send it first and read stdout through a pipe, so they
never see the coloured output. NO_COLOR turns it off. On Windows the
console gets ANSI processing and UTF-8 output.

Checked: the UCI output of a scripted session (two searches with tree
reuse, a stalemate root) is identical to main apart from nps and time;
go wtime, go infinite with stop, and quit work; the pretty mode was
driven in a real console, including the switch to UCI. Search is
untouched, so the bench is unchanged.

Bench: 546018

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rektdieandclaude committed 2026-11-15 14:15:49 +01:00
1 parent 1754753a6e
commit 6490286852
6 files changed
+319 -17

No files matched your search

+3
View File
@@ -87,6 +87,8 @@ class Searcher {
public:
SearchParams params;
std::atomic<bool> stop_flag{false};
// Coloured output for a human at a terminal instead of UCI info lines.
bool pretty = false;
Searcher();
@@ -148,6 +150,7 @@ private:
u32 best_child(u32 idx) const;
void print_info() const;
void print_root_moves() const;
};
} // namespace rigby