package tictactoe_test
import (
"math"
"testing"
"tictactoe"
"github.com/matryer/is"
)
func TestMinimax(t *testing.T) {
is := is.NewRelaxed(t)
var testCases = []struct {
scores []int
expected int
}{
{[]int{3, 5}, 5},
{[]int{3, 5, 2, 9}, 3},
{[]int{3, 5, 2, 9, 12, 5, 23, 23}, 12},
{[]int{3, 5, 2, 9, 1, 2, 3}, 3},
}
for _, tc := range testCases {
height := math.Log2(float64(len(tc.scores)))
t.Run("Minimax", func(t *testing.T) {
is.Equal(tc.expected, tictactoe.Minimax(0, 0, true, tc.scores, int(height)))
})
}
}