~bonbon/gmcts

b588a96f6d5f4f071ebb96798715bb483e2ee46a — bonbon 1 year, 6 months ago cb17487
NewMCTS: check if each inital action is comparable

the old implementation was flawed. It checked if the Action
type was comparable which always returned true.

This change checks the base type of each action returned
from the inital state, and checks if each type is comparable.

The reason we check each separate action is that there's no
reason that the slice won't contain multiple base types.
1 files changed, 7 insertions(+), 3 deletions(-)

M mcts.go
M mcts.go => mcts.go +7 -3
@@ 17,9 17,13 @@ func NewMCTS(initial Game) *MCTS {
	}

	//Check if Action type is comparable
	action := initial.GetActions()
	if !reflect.TypeOf(action).Elem().Comparable() {
		panic("gmcts: action type is not comparable")
	//We only need to check the actions that can affect the initial gamestate
	//as those are the only actions that need to be compared.
	actions := initial.GetActions()
	for i := range actions {
		if !reflect.TypeOf(actions[i]).Comparable() {
			panic("gmcts: action type is not comparable")
		}
	}

	return &MCTS{