update
This commit is contained in:
51
src/mcts.jl
51
src/mcts.jl
@@ -264,36 +264,9 @@ end
|
||||
Signature\n
|
||||
-----
|
||||
"""
|
||||
isLeaf(node::MCTSNode)::Bool = isempty(node.children)
|
||||
isleaf(node::MCTSNode)::Bool = isempty(node.children)
|
||||
|
||||
|
||||
"""
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
|
||||
Return\n
|
||||
-----
|
||||
|
||||
Example\n
|
||||
-----
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
TODO\n
|
||||
-----
|
||||
[] update docstring
|
||||
[] implement the function
|
||||
[] implement RAG to pull similar experience
|
||||
|
||||
Signature\n
|
||||
-----
|
||||
"""
|
||||
function isTerminal()
|
||||
|
||||
end
|
||||
|
||||
"""
|
||||
|
||||
Arguments\n
|
||||
@@ -324,10 +297,12 @@ end
|
||||
# ------------------------------------------------------------------------------------------------ #
|
||||
# Create a complete example using the defined MCTS functions #
|
||||
# ------------------------------------------------------------------------------------------------ #
|
||||
""" Search for best action
|
||||
""" Search the best action to take for a given state and task
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
a::agent
|
||||
one of Yiem's agents
|
||||
initial state
|
||||
initial state
|
||||
decisionMaker::Function
|
||||
@@ -336,6 +311,8 @@ end
|
||||
assess the value of the state
|
||||
reflector::Function
|
||||
generate lesson from trajectory and reward
|
||||
isterminal::Function
|
||||
determine whether a given state is a terminal state
|
||||
n::Integer
|
||||
how many times action will be sampled from decisionMaker
|
||||
w::Float64
|
||||
@@ -359,15 +336,23 @@ end
|
||||
Signature\n
|
||||
-----
|
||||
"""
|
||||
function runMCTS(a::T, initialState, decisionMaker::Function, stateValueEstimator::Function,
|
||||
reflector::Function, n::Integer, maxDepth::Integer,
|
||||
maxIterations::Integer, w::Float64) where {T<:agent}
|
||||
function runMCTS(
|
||||
a::T1,
|
||||
initialState,
|
||||
decisionMaker::Function,
|
||||
stateValueEstimator::Function,
|
||||
reflector::Function,
|
||||
isterminal::Function,
|
||||
n::Integer,
|
||||
maxDepth::Integer,
|
||||
maxIterations::Integer, w::Float64) where {T1<:agent}
|
||||
|
||||
statetype = typeof(initialState)
|
||||
root = MCTSNode(initialState, 0, 0.0, Dict{statetype, MCTSNode}())
|
||||
|
||||
for _ in 1:maxIterations
|
||||
node = root
|
||||
while !isLeaf(node)
|
||||
while !isleaf(node)
|
||||
node = select(node, w)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user