update
This commit is contained in:
@@ -52,7 +52,8 @@ function runMCTS(
|
||||
earlystop::Union{Function,Nothing}=nothing
|
||||
)::NamedTuple{(:bestNextState, :bestFinalState),Tuple{T,T}} where {T<:Any}
|
||||
|
||||
root = MCTSNode("root", initialstate, 0, 0, 0, 0, false, nothing, Dict{String,MCTSNode}())
|
||||
root = MCTSNode("root", initialstate, 0, 0, 0, 0, false, nothing, Dict{String,MCTSNode}(),
|
||||
Dict{Symbol,Any}())
|
||||
|
||||
for nth in 1:maxiterations
|
||||
node = root
|
||||
@@ -67,7 +68,7 @@ function runMCTS(
|
||||
# do nothing then go directly to backpropagation. It means the end of this iteration
|
||||
backpropagate(node, node.reward)
|
||||
else
|
||||
expand(node, transition, transitionargs;
|
||||
_ = expand(node, transition, transitionargs;
|
||||
totalsample=totalsample)
|
||||
leafNode = selectChildNode(node)
|
||||
simTrajectoryReward, terminalstate = simulate(leafNode, transition, transitionargs;
|
||||
@@ -82,6 +83,9 @@ function runMCTS(
|
||||
# end
|
||||
|
||||
backpropagate(leafNode, simTrajectoryReward)
|
||||
|
||||
# delete all child node, no need for child node that was created during simulation
|
||||
leafNode.children = Dict{String,MCTSNode}()
|
||||
end
|
||||
|
||||
# stop if the early stop condition is met
|
||||
|
||||
Reference in New Issue
Block a user