update
This commit is contained in:
+7
-9
@@ -272,8 +272,8 @@ end
|
||||
A user function that handles how state transition.
|
||||
- `transitionargs::NamedTuple`
|
||||
Arguments for everything the user will use within transition().
|
||||
- `maxdepth::Integer`
|
||||
maximum depth level MCTS goes vertically.
|
||||
- `maxSimulationDepth::Integer`
|
||||
maximum depth level MCTS goes vertically during simulation.
|
||||
- horizontalSample::Integer
|
||||
Total number to sample from the current node (i.e. expand new node horizontally)
|
||||
|
||||
@@ -282,15 +282,14 @@ end
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function simulate(outputchannel::Channel, node::MCTSNode, transition::Function, transitionargs::NamedTuple;
|
||||
maxdepth::Integer=3, horizontalSample::Integer=3
|
||||
)::NamedTuple{(:simTrajectoryReward, :terminalstate), Tuple{Number, Union{Dict{Symbol, Any}, Nothing}}}
|
||||
function simulate(node::MCTSNode, transition::Function, transitionargs::NamedTuple;
|
||||
maxSimulationDepth::Integer=3, horizontalSample::Integer=3)
|
||||
# )::NamedTuple{(:simTrajectoryReward, :terminalstate), Tuple{Number, Union{Dict{Symbol, Any}, Nothing}}}
|
||||
|
||||
simTrajectoryReward = 0.0
|
||||
terminalstate = nothing
|
||||
# listOfSimulatedNodeId = []
|
||||
|
||||
for depth in 1:maxdepth
|
||||
for depth in 1:maxSimulationDepth
|
||||
simTrajectoryReward += node.reward
|
||||
if node.isterminal
|
||||
terminalstate = node.state
|
||||
@@ -302,8 +301,7 @@ function simulate(outputchannel::Channel, node::MCTSNode, transition::Function,
|
||||
end
|
||||
end
|
||||
|
||||
put!(outputchannel, (simTrajectoryReward=simTrajectoryReward, terminalstate=terminalstate))
|
||||
# return (simTrajectoryReward=simTrajectoryReward, terminalstate=terminalstate)
|
||||
return (simTrajectoryReward=simTrajectoryReward, terminalstate=terminalstate)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user