use dict string key

This commit is contained in:
2026-06-25 05:28:28 +07:00
parent 25f539581e
commit 26dc2d7e60
3 changed files with 16 additions and 16 deletions
+12 -12
View File
@@ -120,14 +120,14 @@ end
```jldoctest
julia> using Revise
julia> using YiemAgent, DataStructures
julia> initialState = Dict{Symbol, Any}(
:customerinfo=> Dict{Symbol, Any}(),
:storeinfo=> Dict{Symbol, Any}(),
julia> initialState = Dict{String, Any}(
"customerinfo"=> Dict{String, Any}(),
"storeinfo"=> Dict{String, Any}(),
:thoughtHistory=> OrderedDict{Symbol, Any}(
:question=> "How are you?",
)
)
"thoughtHistory"=> OrderedDict{String, Any}(
"question"=> "How are you?",
)
)
julia> statetype = typeof(initialState)
julia> root = YiemAgent.MCTSNode(initialState, 0, 0.0, Dict{statetype, YiemAgent.MCTSNode}())
julia> YiemAgent.isleaf(root)
@@ -247,7 +247,7 @@ function _expand(node::MCTSNode,transition::Function, transitionargs::NamedTuple
"""
if newNodeKey keys(node.children)
newNode = MCTSNode(newNodeKey, newstate, 0, progressvalue, 0, newstate[:reward],
newstate[:isterminal], node, Dict{String, MCTSNode}(), Dict{Symbol, Any}())
newstate[:isterminal], node, Dict{String, MCTSNode}(), Dict{String, Any}())
node.children[newNodeKey] = newNode
end
end
@@ -273,14 +273,14 @@ end
# Return
- `simTrajectoryReward::Number`
Cumulative reward collected along the simulation trajectory
- `terminalstate::Union{Dict{Symbol, Any}, Nothing}`
- `terminalstate::Union{Dict{String, Any}, Nothing}`
Final state if terminal state reached, nothing otherwise
# Signature
"""
function simulate(node::MCTSNode, transition::Function, transitionargs::NamedTuple;
maxSimulationDepth::Integer=3, horizontalSample::Integer=3, multithread=false
)::NamedTuple{(:simTrajectoryReward, :terminalstate), Tuple{<:Number, Union{Dict{Symbol, Any}, Nothing}}}
)::NamedTuple{(:simTrajectoryReward, :terminalstate), Tuple{<:Number, Union{Dict{String, Any}, Nothing}}}
simTrajectoryReward = 0.0
terminalstate = nothing
@@ -319,7 +319,7 @@ end
# Whether this state is terminal
# # Return
# - `Tuple{String, Dict{Symbol, <:Any}}`
# - `Tuple{String, Dict{String, <:Any}}`
# A tuple containing:
# - A unique node key string
# - A new state dictionary with updated thought history and metadata
@@ -333,7 +333,7 @@ end
# """
# function makeNewState(currentstate::T1, thoughtDict::T4, response::T2, select::Union{T3, Nothing},
# reward::T3, isterminal::Bool
# )::Tuple{String, Dict{Symbol, <:Any}} where {T1<:AbstractDict, T2<:AbstractString, T3<:Number, T4<:AbstractDict}
# )::Tuple{String, Dict{String, <:Any}} where {T1<:AbstractDict, T2<:AbstractString, T3<:Number, T4<:AbstractDict}
# # Find the latest thought key and index from current state's thought history
# currentstate_latestThoughtKey, currentstate_latestThoughtIndice =