This commit is contained in:
narawat lamaiin
2024-04-28 11:17:06 +07:00
parent 6f03c60c59
commit 7a3b574272
2 changed files with 24 additions and 26 deletions

View File

@@ -35,32 +35,27 @@ using ..type, ..util, ..llmfunction, ..mcts
""" Think and choose action """ Think and choose action
Arguments\n # Arguments
----- `a::T1`
a::T1 one of Yiem's agent
one of Yiem's agent `state::T2`
state::T2 a game state
a game state
Return\n # Return
----- `thought::Dict`
thought::Dict
Example\n # Example
----- ```jldoctest
```jldoctest julia>
julia> ```
```
TODO\n # TODO
----- [] update docstring
[] update docstring [x] implement the function
[x] implement the function [] implement RAG to pull similar experience
[] implement RAG to pull similar experience [] use iterative prompting to ensure JSON format
[] use iterative prompting to ensure JSON format
Signature\n # Signature
-----
""" """
function decisionMaker(a::T1, state::T2) where {T1<:agent, T2<:AbstractDict} function decisionMaker(a::T1, state::T2) where {T1<:agent, T2<:AbstractDict}
customerinfo = customerinfo =

View File

@@ -134,14 +134,17 @@ function expand(a::T1, node::MCTSNode, state::T2, decisionMaker::Function, state
# sampling action from decisionMaker # sampling action from decisionMaker
for sample in 1:n for sample in 1:n
thought = decisionMaker(a, state) thoughtJstr = decisionMaker(a, state)
thoughtDict = copy(JSON3.read(thoughtJstr))
latestActionKey = GeneralUtils.findHighestIndexKey(thoughtDict, "Action")
error("--> expand")
newState = transition(node.state, action) #[] Implement your transition function newState = transition(node.state, action) #[] Implement your transition function
if newState keys(node.children) if newState keys(node.children)
node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}()) node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}())
end end
end end
error("--> expand")
end end
""" """