M models.go => models.go +1 -1
@@ 67,7 67,7 @@ type node struct {
actionCount int
nodeScore map[Player]float64
- nodeVisits float64
+ nodeVisits int
}
//Tree represents a game state tree
M search.go => search.go +2 -2
@@ 21,10 21,10 @@ func initializeNode(g gameState, tree *Tree) *node {
}
func (n *node) UCT2(i int, p Player) float64 {
- exploit := n.children[i].nodeScore[p] / n.children[i].nodeVisits
+ exploit := n.children[i].nodeScore[p] / float64(n.children[i].nodeVisits)
explore := math.Sqrt(
- math.Log(n.nodeVisits) / n.childVisits[i],
+ math.Log(float64(n.nodeVisits)) / n.childVisits[i],
)
return exploit + n.tree.explorationConst*explore