factored out minmax into AI class