Skip to content

Commit

Permalink
Fix bug in getBestChild
Browse files Browse the repository at this point in the history
  • Loading branch information
pbsinclair42 committed Feb 27, 2019
1 parent bba06d4 commit 7403c69
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mcts.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ def getBestChild(self, node, explorationValue):
for child in node.children.values():
nodeValue = child.totalReward / child.numVisits + explorationValue * math.sqrt(
2 * math.log(node.numVisits) / child.numVisits)
if nodeValue >= bestValue:
if nodeValue > bestValue:
bestValue = nodeValue
bestNodes = [child]
elif nodeValue == bestValue:
bestNodes.append(child)
return random.choice(bestNodes)

Expand Down

0 comments on commit 7403c69

Please sign in to comment.