This commit is contained in:
narawat lamaiin
2024-07-10 17:30:30 +07:00
parent 05830f3d9a
commit 32dec4b47c
2 changed files with 6 additions and 10 deletions

View File

@@ -32,7 +32,7 @@ using ..type, ..mcts, ..util
aggressively explore new state. aggressively explore new state.
# Return # Return
- `(bestNextState, BestFinalState)::@NamedTuple{bestNextState::T, bestFinalState::T}` - `NamedTuple{(:bestNextState, :bestFinalState), Tuple{T, T}}`
the best next state and the best final state the best next state and the best final state
# Example # Example
@@ -49,7 +49,7 @@ function runMCTS(
maxdepth::Integer=3, maxdepth::Integer=3,
maxiterations::Integer=10, maxiterations::Integer=10,
explorationweight::Number=1.0, explorationweight::Number=1.0,
)::@NamedTuple{bestNextState::T, bestFinalState::T} where {T<:Any} )::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}())

View File

@@ -196,11 +196,6 @@ end
# Return # Return
- None - None
# Example
```jldoctest
julia>
```
# Signature # Signature
""" """
function expand(node::MCTSNode,transition::Function, transitionargs::NamedTuple; function expand(node::MCTSNode,transition::Function, transitionargs::NamedTuple;
@@ -249,13 +244,14 @@ end
Total number to sample from the current node (i.e. expand new node horizontally) Total number to sample from the current node (i.e. expand new node horizontally)
# Return # Return
- `(simTrajectoryReward, terminalstate)::Union{Tuple{Number, Dict{Symbol, <:Any}}, Tuple{Number, Nothing}}` - `::NamedTuple{(:simTrajectoryReward, :terminalstate), Tuple{Number, Union{Dict{Symbol, Any}, Nothing}}}`
# Signature # Signature
""" """
function simulate(node::MCTSNode, transition::Function, transitionargs::NamedTuple; function simulate(node::MCTSNode, transition::Function, transitionargs::NamedTuple;
maxdepth::Integer=3, totalsample::Integer=3 maxdepth::Integer=3, totalsample::Integer=3
)::Union{Tuple{Number, Dict{Symbol, <:Any}}, Tuple{Number, Nothing}} )::NamedTuple{(:simTrajectoryReward, :terminalstate), Tuple{Number, Union{Dict{Symbol, Any}, Nothing}}}
simTrajectoryReward = 0.0 simTrajectoryReward = 0.0
terminalstate = nothing terminalstate = nothing
@@ -271,7 +267,7 @@ function simulate(node::MCTSNode, transition::Function, transitionargs::NamedTup
end end
end end
return (simTrajectoryReward, terminalstate) return (simTrajectoryReward=simTrajectoryReward, terminalstate=terminalstate)
end end