~bonbon/gmcts

052df34072b069e95496e1379efc0c4d06a84672 — bonbon 1 year, 5 months ago 95d4547 v1.2.1
reduce amount of IsTerminal calls

we only need to check it if a node hasn't been expanded yet
1 files changed, 10 insertions(+), 4 deletions(-)

M search.go
M search.go => search.go +10 -4
@@ 34,10 34,16 @@ func (n *node) runSimulation() ([]Player, float64) {
	var selectedChildIndex int
	var winners []Player
	var scoreToAdd float64

	terminalState := n.state.IsTerminal()
	if !terminalState && n.actionCount == 0 {
		n.expand()
	var terminalState bool

	//If we have actions, then there's no need to expand.
	if n.actionCount == 0 {
		//If we don't have any actions, then either the state
		//is terminal, or we haven't expanded the node yet.
		terminalState = n.state.IsTerminal()
		if !terminalState {
			n.expand()
		}
	}

	if terminalState {