~bonbon/gmcts

698483e3eafccc0ae6e52debbe1f23622a95129c — bonbon 1 year, 6 months ago 1ee168f
switch node.nodeVisits from float64 to int
2 files changed, 3 insertions(+), 3 deletions(-)

M models.go
M search.go
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