From 75c500ba61241afc2cca81298f9105f4f0d31031 Mon Sep 17 00:00:00 2001 From: rektdie Date: Sun, 15 Nov 2026 16:11:51 +0100 Subject: [PATCH] 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 --- src/mcts.cpp | 6 +++++- src/mcts.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mcts.cpp b/src/mcts.cpp index 0530707..2383b67 100644 --- a/src/mcts.cpp +++ b/src/mcts.cpp @@ -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(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(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; diff --git a/src/mcts.h b/src/mcts.h index c766761..7c8d6b4 100644 --- a/src/mcts.h +++ b/src/mcts.h @@ -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;