Solvers · Live
Tic-Tac-Toe Solver,
powered by Minimax.
Play against an unbeatable AI, set up any board position in Edit mode, and ask for the optimal move at any point. Every decision is driven by the Minimax algorithm with alpha-beta pruning — the bot is mathematically incapable of losing.
You play as
Who goes first
Searches the full game tree with alpha-beta pruning. The bot never loses — optimal play always draws or wins.
Algorithm guide
How the Tic-Tac-Toe Solver works.
The solver uses the Minimax algorithm: a decision-tree search that models both players making optimal choices, then selects the move that minimises the maximum possible loss. Since Tic-Tac-Toe is a solved game with a finite, shallow search tree (at most 9 plies), Minimax can examine every possible future without sampling or heuristics.
The Minimax algorithm, step by step
At any board state, Minimax assigns a score: +10 if the maximising player (the bot) wins, −10 if the minimising player (you) wins, and 0 for a draw. The depth is subtracted from wins so the bot prefers faster victories and avoids prolonging hopeless positions.
Starting from the current board, the algorithm recursively generates every legal next move. At each level, the maximising player picks the move with the highest score; the minimising player picks the move with the lowest. The returned value propagates back up the tree, and the root picks the branch with the best score for the bot.
Alpha-beta pruning
This solver extends Minimax with alpha-beta pruning, which maintains two bounds: alpha (the best score the maximiser is guaranteed) and beta (the best score the minimiser is guaranteed). Whenever a branch cannot possibly influence the final decision (beta ≤ alpha), the search abandons it early. In practice this cuts the number of nodes evaluated by roughly half, making the response instantaneous even on mobile.
Why the bot never loses
Tic-Tac-Toe is a perfect information, zero-sum gamewith no randomness. Game-theoretic analysis shows that with optimal play from both sides the result is always a draw. Against sub-optimal play the bot will always find and exploit mistakes. It is therefore impossible for the AI to lose — the worst case is a draw.
Using Edit mode for position analysis
Switch to Edit Board to set up any legal position. Click cells to place or remove pieces, or paste a 9-character string (X, O, or – for empty) such as XO--X--O-. Then click Best move to see the optimal play highlighted on the board. This is useful for studying opening theory, endgame patterns, or verifying that a position is won, drawn, or lost for a specific player.
Worked example: the fork trap
One of the most common beginner traps is creating a fork: placing a piece that simultaneously threatens two winning lines. The opponent can only block one, so you win the next move. The Minimax bot will never fall into a fork — it recognises the double-threat and blocks the square that prevents it. To see this in action, enter the board string X-O-X---- and request the best move for O: the solver will correctly block the centre-column fork rather than taking a naive winning-looking edge.
Keyboard accessibility
The board grid is keyboard-navigable: use Tab to move between cells and Space or Enter to select. Screen readers announce each cell's position and current state (X, O, or empty).