Puzzle

Tic Tac Toe

🎮 Single Player📱 Mobile Friendly⚡ Instant Load

Tic Tac Toe puts you against an AI opponent that uses the minimax algorithm to play optimally. The game is played on a standard 3x3 grid. You are X (orange) and the AI is O (blue). Players take turns placing their marks in empty cells. Three marks in a row (horizontally, vertically, or diagonally) wins the game. If all nine cells are filled without a winner, the game is a draw. The AI's strategy is based on optimal play: it first checks if it can win immediately, then checks if it needs to block your winning move, then prioritizes the center square, and finally selects a corner or side square. Against optimal play, the game always results in either a win for the starting player (if the opponent makes a mistake) or a draw (if both players play perfectly).

Tic Tac Toe is a solved game — with perfect play from both players, the game always ends in a draw. The first player has a slight advantage and can force a win if the second player makes a single mistake. Our AI is designed to challenge casual players while never making intentionally "dumb" moves to let the player win. This creates a fair test of the player's strategic ability. The game tracks three statistics across sessions: wins, losses, and draws. These are saved to localStorage so you can track your improvement over time. The visual interface uses a clean grid layout with animated mark placements. When a player wins, the winning row is highlighted with a pulsing animation. The game is fully DOM-based for instant loading, with no Canvas dependency. Touch targets are at least 48px on mobile, exceeding Google's mobile usability guidelines. The AI's moves are deliberately delayed by 300ms to simulate natural thinking time.

Controls

Click/TaporArrow Keysto play

Strategy Guide

Tic Tac Toe's AI is unbeatable because it uses the minimax algorithm with alpha-beta pruning. The algorithm evaluates all possible board states and chooses the move that maximizes its minimum guaranteed outcome. Against a perfect opponent, every game ends in a draw. The AI plays from the perspective of having memorized all 5478 possible board positions. The key strategy against a non-perfect AI: control the center square on your first move. The center provides access to four winning lines (row, column, both diagonals) versus corners (three lines) and edges (two lines). The AI's difficulty slider adjusts the search depth: easy mode limits the AI to looking only 1 move ahead, medium looks 3 moves ahead, and hard evaluates the full game tree. Players who understand the fork strategy (creating two simultaneous threats) can beat medium difficulty consistently.

Play Tips

Against the medium AI (3-ply search), the fork strategy is dominant. Create two simultaneous winning threats: for example, placing in the corner opens up both a diagonal win and a row win after your next move. The AI cannot block both threats if you set up correctly. The sequence: corner → center (if available) → opposite corner. This creates a double-threat fork on your third move. The AI blocks one threat but cannot block both. This specific sequence wins against any non-perfect player and works in approximately 20% of starting board configurations.