From 48deb7934e598898c24e2e6f080e0841dd6889f0 Mon Sep 17 00:00:00 2001 From: narawat lamaiin Date: Sat, 11 May 2024 16:47:57 +0700 Subject: [PATCH] update --- src/mcts.jl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mcts.jl b/src/mcts.jl index 37efc01..d3edab1 100644 --- a/src/mcts.jl +++ b/src/mcts.jl @@ -513,13 +513,17 @@ function runMCTS( end end - best_child_state = argmax([child.statevalue / child.visits for child in values(root.children)]) + avgStateValue = 0 + selectedChildKey = nothing + for (k, v) in root.children + k_avgStateValue = v.statevalue / v.visits + if k_avgStateValue > avgStateValue + avgStateValue = k_avgStateValue + selectedChildKey = k + end + end - - - - - return best_child_state + return root.children[selectedChildKey] end