update
This commit is contained in:
35
src/mcts.jl
35
src/mcts.jl
@@ -121,15 +121,28 @@ function expand(a::T1, node::MCTSNode, state::T2, decisionMaker::Function, state
|
||||
for sample in 1:n
|
||||
thoughtJstr = decisionMaker(a, state)
|
||||
thoughtDict = copy(JSON3.read(thoughtJstr))
|
||||
|
||||
""" Example of thoughtDict
|
||||
Dict{Symbol, Any} with 3 entries:
|
||||
:Thought_1 => "The customer wants to buy a bottle of wine. This is a good start!"
|
||||
:Action_1 => Dict{Symbol, Any}(
|
||||
:action=>"Chatbox",
|
||||
:input=>"What occasion are you buying the wine for?"
|
||||
)
|
||||
:Observation_1 => ""
|
||||
"""
|
||||
latestActionKey = GeneralUtils.findHighestIndexKey(thoughtDict, "Action")
|
||||
_action = thoughtDict[latestActionKey]
|
||||
action = _action[:action]
|
||||
actioninput = _action[:input]
|
||||
|
||||
error("--> expand")
|
||||
newState = transition(node.state, action) #[] Implement your transition function
|
||||
newState = transition(a, node.state, action, actioninput) #[] Implement your transition function
|
||||
|
||||
if newState ∉ keys(node.children)
|
||||
node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}())
|
||||
end
|
||||
end
|
||||
|
||||
error("--> expand")
|
||||
end
|
||||
|
||||
"""
|
||||
@@ -192,9 +205,17 @@ function backpropagate(node::MCTSNode, reward::Float64)
|
||||
end
|
||||
end
|
||||
|
||||
"""
|
||||
""" Get a new state
|
||||
|
||||
# Arguments
|
||||
- `a::T1`
|
||||
one of YiemAgent's agent
|
||||
- `state::T2`
|
||||
current game state
|
||||
- `action::String`
|
||||
name of LLM's function to be used
|
||||
- `actioninput::String`
|
||||
input to LLM function
|
||||
|
||||
# Return
|
||||
|
||||
@@ -205,12 +226,14 @@ julia>
|
||||
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [] implement the function
|
||||
- [WORKING] implement the function
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function transition(state, action)
|
||||
function transition(a::T1, state::T2, action::T3,
|
||||
actioninput::T3) where {T1<:agent, T2<:AbstractDict, T3<:AbstractString}
|
||||
|
||||
error("--> transition")
|
||||
end
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user