feat: cpuct grows with the parent's visits

The exploration constant was fixed at 1.6. With tree reuse the root and
the nodes near it reach hundreds of thousands of visits, where a fixed
cpuct leaves the other children almost no chance. Now, as in Monty,
cpuct is multiplied by 1 + ln((N + 8192) / 8192) for a node with N
visits (Monty's default scale, 64 x 128; the factor is independent of
the Q range). Nodes under a few thousand visits are nearly unchanged;
at 10k visits cpuct is x1.8, at 1M x5.8.

Checked: the best move is the same as main's in four positions at 200k
playouts (Qxf7# included). The log costs up to about 10% speed in fast
endgame playouts.

Bench: 536817

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rektdieandclaude committed 2026-11-15 16:11:51 +01:00
1 parent d8b1d6ef6f
commit 75c500ba61
2 files changed
+8 -1

No files matched your search

+5 -1
View File
@@ -368,7 +368,11 @@ u32 Searcher::select_child(u32 idx) const {
}
const float fpu = parent_q - params.fpu_reduction * std::sqrt(visited_policy);
const float explore = params.cpuct * std::sqrt(float(std::max<u32>(node.visits, 1)));
// Exploration grows with the visits (Monty's scaling): a node searched a
// lot keeps giving its other children a chance.
const float n = float(std::max<u32>(node.visits, 1));
const float cpuct = params.cpuct * (1.0f + std::log((n + params.cpuct_visit_scale) / params.cpuct_visit_scale));
const float explore = cpuct * std::sqrt(n);
u32 best = node.first_child;
float best_score = -1e30f;
+3
View File
@@ -97,6 +97,9 @@ struct SearchLimits {
struct SearchParams {
float cpuct = 1.60f;
// cpuct is multiplied by 1 + ln((N + scale) / scale) for a node with N visits
// (Monty: 64 x 128).
float cpuct_visit_scale = 8192.0f;
float fpu_reduction = 0.30f;
float policy_temperature = 1.00f;
i64 move_overhead = 20;