Generalized tic-tac-toe game with AI