~bonbon/gmcts

54cb30128f55c35501aaf7f188d699c1546ee09f — bonbon 1 year, 6 months ago 3ba336b
create tests relating to (*MCTS).BestAction()

these tests check to see if BestAction returns nil
when it does not have enough information or just can't
1 files changed, 19 insertions(+), 0 deletions(-)

M mcts_test.go
M mcts_test.go => mcts_test.go +19 -0
@@ 127,3 127,22 @@ func TestTicTacToeMiddle(t *testing.T) {
		t.FailNow()
	}
}

func TestZeroTrees(t *testing.T) {
	mcts := NewMCTS(finishedGame)
	bestAction := mcts.BestAction()
	if bestAction != nil {
		t.Errorf("gmcts: recieved a best action from no trees: %#v", bestAction)
		t.FailNow()
	}
}

func TestTerminalState(t *testing.T) {
	mcts := NewMCTS(finishedGame)
	mcts.AddTree(mcts.SpawnTree())
	bestAction := mcts.BestAction()
	if bestAction != nil {
		t.Errorf("gmcts: recieved a best action from a terminal state: %#v", bestAction)
		t.FailNow()
	}
}