Minimax algorithm (via a Tic-Tac-Toe variant)