implements game loop and minimax