From c33d69b00c6b60d2bb1ec27046f08db351b153dc Mon Sep 17 00:00:00 2001 From: narawat lamaiin Date: Tue, 20 Aug 2024 20:18:10 +0700 Subject: [PATCH] update --- src/mcts.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mcts.jl b/src/mcts.jl index 24a944e..d03bb78 100644 --- a/src/mcts.jl +++ b/src/mcts.jl @@ -203,14 +203,17 @@ end """ function expand(node::MCTSNode, transition::Function, transitionargs::NamedTuple; totalsample::Integer=3) - results = Any[] + + # not use Any[] because I want to preserve result order + results = Vector{Any}(undef, totalsample) + @sync for i in 1:totalsample @spawn begin - results[i] = transition(deepcopy(node.state), deepcopy(transitionargs)) + result = transition(deepcopy(node.state), deepcopy(transitionargs)) + results[i] = result end - println("--> sampling $i") end - + for result in results newNodeKey::AbstractString = result[:newNodeKey] newstate::AbstractDict = result[:newstate]