This commit is contained in:
narawat lamaiin
2024-04-24 08:02:01 +07:00
parent 1962035990
commit 445bb11592
3 changed files with 151 additions and 14 deletions

View File

@@ -17,11 +17,24 @@ using GeneralUtils
Arguments\n
-----
state::T
Represent a state of a game. Can be a Dict or something else.
a state of a game. Can be a Dict or something else.
For example:
state = Dict(
:info=> Dict(), # keyword info
:thoughtHistory=> Dict(
:question=> _,
:thought_1=> _,
:action_1=> _,
:observation_1=> _,
:thought_2=> _,
...
)
)
visits::Integer
number of time the game visits this state
stateValue::Float64
state value
Return\n
-----
@@ -46,7 +59,7 @@ struct MCTSNode{T}
children::Dict{T, MCTSNode}
end
"""
""" Select a node based on UCT score
Arguments\n
-----
@@ -87,10 +100,16 @@ function select(node::MCTSNode, w::Float64)
return selectedNode
end
"""
""" Expand selected node
Arguments\n
-----
node::MCTSNode
MCTS node
state::T
a state of a game. Can be a Dict or something else.
decisionMaker::Function
Return\n
-----
@@ -114,6 +133,7 @@ function expand(node::MCTSNode, state::T, decisionMaker::Function, stateValueEst
# sampling action from decisionMaker
for sample in 1:n
result = decisionMaker(state)
newState = transition(node.state, action) #[] Implement your transition function
if newState keys(node.children)
node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}())
@@ -262,7 +282,7 @@ isLeaf(node::MCTSNode)::Bool = isempty(node.children)
-----
[] update docstring
[] implement the function
[] implement RAG to pull similar experience
[WORKING] implement RAG to pull similar experience
Signature\n
-----
@@ -350,6 +370,32 @@ function isTerminal()
end
"""
Arguments\n
-----
Return\n
-----
Example\n
-----
```jldoctest
julia>
```
TODO\n
-----
[] update docstring
[WORKING] implement the function
Signature\n
-----
"""
function executeLLMFunction()
end
# ------------------------------------------------------------------------------------------------ #
# Create a complete example using the defined MCTS functions #