From 698483e3eafccc0ae6e52debbe1f23622a95129c Mon Sep 17 00:00:00 2001 From: bonbon Date: Fri, 10 Jul 2020 03:46:07 -0500 Subject: [PATCH] switch node.nodeVisits from float64 to int --- models.go | 2 +- search.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/models.go b/models.go index 110523a..72a26dd 100644 --- a/models.go +++ b/models.go @@ -67,7 +67,7 @@ type node struct { actionCount int nodeScore map[Player]float64 - nodeVisits float64 + nodeVisits int } //Tree represents a game state tree diff --git a/search.go b/search.go index b779367..22c01e1 100644 --- a/search.go +++ b/search.go @@ -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 -- 2.34.2