This commit is contained in:
narawat lamaiin
2024-06-20 16:54:57 +07:00
parent e9268ce500
commit 202981d287
2 changed files with 12 additions and 12 deletions

View File

@@ -47,17 +47,17 @@ julia>
# Signature
"""
function runMCTS(
initialState,
initialstate,
transition::Function,
args...,
transitionargs::NamedTuple,
;
totalsample::Integer=3,
maxDepth::Integer=3,
maxdepth::Integer=3,
maxiterations::Integer=10,
explorationweight::Number=1.0,
)
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}())
for nth in 1:maxiterations
node = root
@@ -71,11 +71,11 @@ function runMCTS(
# do nothing then go directly to backpropagation
backpropagate(leafNode, node.reward)
else
expand(node, transition, args...;
expand(node, transition, transitionargs;
totalsample=totalsample)
leafNode = selectChildNode(node)
simTrajectoryReward, terminalstate = simulate(leafNode, transition, args...;
maxDepth=maxDepth, totalsample=totalsample)
simTrajectoryReward, terminalstate = simulate(leafNode, transition, transitionargs;
maxdepth=maxdepth, totalsample=totalsample)
if terminalstate !== nothing #XXX not sure why I need this
terminalstate[:totalTrajectoryReward] = simTrajectoryReward
end