Compare commits
1
Commits
main
...
e719da0a44
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e719da0a44 |
No files matched your search
+9
-2
@@ -362,10 +362,17 @@ u32 Searcher::select_child(u32 idx) const {
|
||||
const float parent_q = node.visits ? -node.q : 0.0f;
|
||||
|
||||
float visited_policy = 0.0f;
|
||||
float sum_sq = 0.0f;
|
||||
for (u32 i = 0; i < node.num_children; i++) {
|
||||
const Node& child = tree_[node.first_child + i];
|
||||
if (child.visits) visited_policy += child.prior();
|
||||
const float p = child.prior();
|
||||
if (child.visits) visited_policy += p;
|
||||
sum_sq += p * p;
|
||||
}
|
||||
// A sharp policy gets more exploration, a flat one less (Monty).
|
||||
const float gini = std::clamp(1.0f - sum_sq, 0.0f, 1.0f);
|
||||
const float gini_factor =
|
||||
std::min(params.gini_base - params.gini_ln_multiplier * std::log(gini + 0.001f), params.gini_max);
|
||||
|
||||
const float fpu = parent_q - params.fpu_reduction * std::sqrt(visited_policy);
|
||||
// Exploration grows with the visits (Monty's scaling): a node searched a
|
||||
@@ -374,7 +381,7 @@ u32 Searcher::select_child(u32 idx) const {
|
||||
// The root, where the move is chosen, explores more.
|
||||
const float base_cpuct = idx == Tree::root() ? params.root_cpuct : params.cpuct;
|
||||
const float cpuct = base_cpuct * (1.0f + std::log((n + params.cpuct_visit_scale) / params.cpuct_visit_scale));
|
||||
const float explore = cpuct * std::sqrt(n);
|
||||
const float explore = cpuct * std::sqrt(n) * gini_factor;
|
||||
|
||||
u32 best = node.first_child;
|
||||
float best_score = -1e30f;
|
||||
|
||||
@@ -103,6 +103,12 @@ struct SearchParams {
|
||||
// (Monty: 64 x 128).
|
||||
float cpuct_visit_scale = 8192.0f;
|
||||
float fpu_reduction = 0.30f;
|
||||
// Exploration is multiplied by min(base - mult * ln(gini + 0.001), max),
|
||||
// gini = 1 - sum of the squared priors (Monty's gini_base, gini_ln_multiplier,
|
||||
// gini_min): a sharp policy (gini 0.1) explores 2.25x, a flat one (0.9) 0.67x.
|
||||
float gini_base = 0.5129f;
|
||||
float gini_ln_multiplier = 1.4737f;
|
||||
float gini_max = 2.2546f;
|
||||
float policy_temperature = 1.00f;
|
||||
i64 move_overhead = 20;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user