update
This commit is contained in:
64
src/mcts.jl
64
src/mcts.jl
@@ -131,15 +131,11 @@ function expand(a::T1, node::MCTSNode, state::T2, decisionMaker::Function, state
|
||||
)
|
||||
:Observation_1 => ""
|
||||
"""
|
||||
latestActionKey = GeneralUtils.findHighestIndexKey(thoughtDict, "Action")
|
||||
_action = thoughtDict[latestActionKey]
|
||||
action = _action[:action]
|
||||
actioninput = _action[:input]
|
||||
|
||||
newState = MCTStransition(a, node.state, action, actioninput) #[] Implement your transition function
|
||||
newstate = MCTStransition(a, node.state, thoughtDict) #[] Implement your transition function
|
||||
|
||||
if newState ∉ keys(node.children)
|
||||
node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}())
|
||||
if newstate ∉ keys(node.children)
|
||||
node.children[newstate] = MCTSNode(newstate, 0, 0.0, Dict{T, MCTSNode}())
|
||||
end
|
||||
end
|
||||
error("--> expand")
|
||||
@@ -212,41 +208,61 @@ end
|
||||
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
|
||||
|
||||
- `thoughtDict::T2`
|
||||
contain Thought, Action, Observation
|
||||
|
||||
# Return
|
||||
- `newstate::AbstractDict`
|
||||
next game state
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia>
|
||||
julia> thoughtDict = Dict(
|
||||
:Question=> "I want to buy a bottle of wine."
|
||||
:Thought_1=> "The customer wants to buy a bottle of wine. This is a good start!",
|
||||
:Action_1=> Dict{Symbol, Any}(
|
||||
:name=>"Chatbox",
|
||||
:input=>"What occasion are you buying the wine for?"
|
||||
),
|
||||
:Observation_1 => ""
|
||||
)
|
||||
```
|
||||
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [WORKING] implement the function
|
||||
- [x] update docstring
|
||||
- [TESTING] implement the function
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function MCTStransition(a::T1, state::T2, action::T3,
|
||||
actioninput::T3) where {T1<:agent, T2<:AbstractDict, T3<:AbstractString}
|
||||
|
||||
function MCTStransition(a::T1, state::T2, thoughtDict::T2)::AbstractDict where {T1<:agent, T2<:AbstractDict}
|
||||
latestThoughtKey, latestindice = GeneralUtils.findHighestIndexKey(thoughtDict, "Thought")
|
||||
latestActionKey = GeneralUtils.findHighestIndexKey(thoughtDict, "Action")
|
||||
_action = thoughtDict[latestActionKey]
|
||||
actionname = _action[:name]
|
||||
actioninput = _action[:input]
|
||||
|
||||
# map action and input() to llm function
|
||||
result =
|
||||
if action == "chatbox"
|
||||
virtualWineCustomerChatbox(a, input) # user virtu
|
||||
elseif action == "winestock"
|
||||
response =
|
||||
if actionname == "chatbox"
|
||||
virtualWineCustomerChatbox(a, actioninput) # user virtu
|
||||
elseif actionname == "winestock"
|
||||
|
||||
elseif action == "finish"
|
||||
elseif actionname == "finish"
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
# add Thought, action, observation to thoughtHistory
|
||||
newstate = deepcopy(state)
|
||||
newstate[:thoughtHistory][latestThoughtKey] = thoughtDict[latestThoughtKey]
|
||||
newstate[:thoughtHistory][latestActionKey] = thoughtDict[latestActionKey]
|
||||
latestObservationKey = Symbol("Observation_$(latestindice)")
|
||||
newstate[:thoughtHistory][latestObservationKey] = response
|
||||
|
||||
|
||||
error("--> transition")
|
||||
|
||||
return newstate
|
||||
end
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user