~bonbon/gmcts

3ba336bb6b96cfe851184a0628b3d6b35626b13c — bonbon 1 year, 6 months ago 3ec7baa
add test for (*Tree).Search()
1 files changed, 15 insertions(+), 0 deletions(-)

M tree_test.go
M tree_test.go => tree_test.go +15 -0
@@ 35,3 35,18 @@ func TestDepth(t *testing.T) {
		t.FailNow()
	}
}

func TestSearch(t *testing.T) {
	mcts := NewMCTS(tttGame{tictactoe.NewGame()})
	tree := mcts.SpawnTree()

	timeToSearch := 1 * time.Millisecond
	t0 := time.Now()
	tree.Search(timeToSearch)
	td := time.Now().Sub(t0)

	if td < timeToSearch {
		t.Errorf("Tree was searched for %s: wanted >= %s", td, timeToSearch)
		t.FailNow()
	}
}