update
This commit is contained in:
10
src/mcts.jl
10
src/mcts.jl
@@ -244,13 +244,13 @@ julia>
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function expand(node::MCTSNode,transition::Function, args...; totalsample::Integer=3)
|
||||
function expand(node::MCTSNode,transition::Function, args::NamedTuple; totalsample::Integer=3)
|
||||
|
||||
nthSample = 0
|
||||
while true
|
||||
nthSample += 1
|
||||
if nthSample <= totalsample
|
||||
newNodeKey, newstate, progressvalue = transition(node.state, args...)
|
||||
newNodeKey, newstate, progressvalue = transition(node.state, args)
|
||||
if newNodeKey ∉ keys(node.children)
|
||||
node.children[newNodeKey] =
|
||||
MCTSNode(newNodeKey, newstate, 0, progressvalue, 0, newstate[:reward],
|
||||
@@ -287,19 +287,19 @@ julia>
|
||||
# Signature
|
||||
"""
|
||||
function simulate(node::MCTSNode, transition::Function, args...;
|
||||
maxDepth::Integer=3, totalsample::Integer=3
|
||||
maxdepth::Integer=3, totalsample::Integer=3
|
||||
)::Union{Tuple{Number, Dict{Symbol, <:Any}}, Tuple{Number, Nothing}}
|
||||
|
||||
simTrajectoryReward = 0.0
|
||||
terminalstate = nothing
|
||||
|
||||
for depth in 1:maxDepth
|
||||
for depth in 1:maxdepth
|
||||
simTrajectoryReward += node.reward
|
||||
if node.isterminal
|
||||
terminalstate = node.state
|
||||
break
|
||||
else
|
||||
expand(node, transition, args...;
|
||||
expand(node, transition, args;
|
||||
totalsample=totalsample)
|
||||
node = selectChildNode(node)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user