update
This commit is contained in:
@@ -32,7 +32,7 @@ using ..type, ..mcts, ..util
|
||||
aggressively explore new state.
|
||||
|
||||
# Return
|
||||
- `(bestNextState, BestFinalState)::@NamedTuple{bestNextState::T, bestFinalState::T}`
|
||||
- `NamedTuple{(:bestNextState, :bestFinalState), Tuple{T, T}}`
|
||||
the best next state and the best final state
|
||||
|
||||
# Example
|
||||
@@ -49,7 +49,7 @@ function runMCTS(
|
||||
maxdepth::Integer=3,
|
||||
maxiterations::Integer=10,
|
||||
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}())
|
||||
|
||||
|
||||
12
src/mcts.jl
12
src/mcts.jl
@@ -196,11 +196,6 @@ end
|
||||
# Return
|
||||
- None
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
# Signature
|
||||
"""
|
||||
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)
|
||||
|
||||
# Return
|
||||
- `(simTrajectoryReward, terminalstate)::Union{Tuple{Number, Dict{Symbol, <:Any}}, Tuple{Number, Nothing}}`
|
||||
- `::NamedTuple{(:simTrajectoryReward, :terminalstate), Tuple{Number, Union{Dict{Symbol, Any}, Nothing}}}`
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function simulate(node::MCTSNode, transition::Function, transitionargs::NamedTuple;
|
||||
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
|
||||
terminalstate = nothing
|
||||
|
||||
@@ -271,7 +267,7 @@ function simulate(node::MCTSNode, transition::Function, transitionargs::NamedTup
|
||||
end
|
||||
end
|
||||
|
||||
return (simTrajectoryReward, terminalstate)
|
||||
return (simTrajectoryReward=simTrajectoryReward, terminalstate=terminalstate)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user