This commit is contained in:
narawat lamaiin
2024-05-11 16:30:21 +07:00
parent 2e9c21f243
commit 724519f74b
2 changed files with 13 additions and 5 deletions

View File

@@ -407,6 +407,9 @@ function selectChildNode(node::MCTSNode)::MCTSNode
# loop thought node children dictionary to find the highest progress value # loop thought node children dictionary to find the highest progress value
for (k, childNode) in node.children for (k, childNode) in node.children
potential = childNode.progressvalue + childNode.reward potential = childNode.progressvalue + childNode.reward
if childNode.reward > 0 #XXX for testing. remove when done.
println("")
end
if potential > highestProgressValue if potential > highestProgressValue
highestProgressValue = potential highestProgressValue = potential
nodekey = childNode.nodekey nodekey = childNode.nodekey
@@ -485,7 +488,8 @@ function runMCTS(
n::Integer, n::Integer,
maxDepth::Integer, maxDepth::Integer,
maxIterations::Integer, maxIterations::Integer,
w::Float64) where {T1<:agent} w::Float64
) where {T1<:agent}
root = MCTSNode("root", initialState, 0, 0, 0, 0, false, nothing, Dict{String, MCTSNode}()) root = MCTSNode("root", initialState, 0, 0, 0, 0, false, nothing, Dict{String, MCTSNode}())
@@ -510,7 +514,11 @@ function runMCTS(
end end
best_child_state = argmax([child.statevalue / child.visits for child in values(root.children)]) best_child_state = argmax([child.statevalue / child.visits for child in values(root.children)])
error("---> runMCTS")
return best_child_state return best_child_state
end end

View File

@@ -162,10 +162,10 @@ result = GeneralUtils.sendMqttMsg(outgoingMsg)
outgoingMsg = Dict( outgoingMsg = Dict(
:msgMeta=> msgMeta, :msgMeta=> msgMeta,
:payload=> Dict( :payload=> Dict(
:text=> "You didn't tell me wine name.", :text=> "Yes.",
:select=> nothing, :select=> nothing,
:reward=> -1, :reward=> 0,
:isterminal=> true, :isterminal=> false,
) )
) )
result = GeneralUtils.sendMqttMsg(outgoingMsg) result = GeneralUtils.sendMqttMsg(outgoingMsg)