~bonbon/gmcts

95d454781dbe4ddbed82e8a9a8fa860e4d4a21c4 — bonbon 1 year, 6 months ago f53b192
remove isParentOf func

The reason this function existed was to filter duplicate moves from
the same game state. The reason for its removal is that the filtering
of moves should be moved onto the user of this package. 9 times out of
10, there would be no moves to filter, so it just wastes cpu cycles on
searching for a non-existent duplicate through the node's children. This
loop would occur each time a duplicate game state was found, wasting
time for games where duplicate states are common.
1 files changed, 0 insertions(+), 13 deletions(-)

M search.go
M search.go => search.go +0 -13
@@ 79,15 79,6 @@ func (n *node) runSimulation() ([]Player, float64) {
	return winners, scoreToAdd
}

func (n *node) isParentOf(potentialChild *node) bool {
	for _, child := range n.children {
		if child != nil && child == potentialChild {
			return true
		}
	}
	return false
}

func (n *node) expand() {
	n.actions = n.state.GetActions()
	n.actionCount = len(n.actions)


@@ 105,10 96,6 @@ func (n *node) expand() {
		//If we already have a copy in cache, use that and update
		//this node and its parents
		if cachedNode, made := n.tree.gameStates[newState]; made {
			if n.isParentOf(cachedNode) {
				continue
			}

			n.unvisitedChildren[i] = cachedNode
		} else {
			newNode := initializeNode(newState, n.tree)