Tic-Tac-Toe
You're X. Try to beat the AI!
About Tic-Tac-Toe
Tic-Tac-Toe (also known as Noughts and Crosses or Xs and Os) is one of the oldest and most universally known strategy games in human history. Archaeological evidence suggests variants were played in ancient Egypt as far back as 1300 BCE, and the Romans played a version called Terni Lapilli. Despite its simplicity, the game has fascinated mathematicians — it was one of the first games fully analyzed using game theory, proving that perfect play always results in a draw.
While the game is "solved" at the expert level, it remains an excellent introduction to strategic thinking. Playing against an AI that uses perfect strategy (minimax algorithm on Hard mode) teaches important concepts like controlling the center, creating double threats, and defensive play. For newer players, the Easy and Medium modes provide a more relaxed experience where wins are achievable.
This digital version offers three difficulty levels so players of all ages and skill levels can enjoy it. The hard AI is unbeatable (the best you can do is draw), making it a genuine test of whether you have mastered the game's strategy. It is the perfect quick game when you have a minute to spare.
How to Play
Two players alternate placing their marks (X and O) on a 3×3 grid. You play as X and move first.
- Click any empty square to place your X
- The AI responds with O after a short delay
- Get three of your marks in a row — horizontally, vertically, or diagonally — to win
- Block the AI from completing three in a row to prevent losing
- If all 9 squares are filled with no winner, the game is a draw
- Select difficulty before playing: Easy (random moves), Medium (some strategy), Hard (perfect play)
Tips & Strategy
- Take the center square if it is available — it participates in the most winning lines (4 out of 8)
- If the center is taken, corners are the next strongest opening — they participate in 3 winning lines each
- Create a "fork": place your marks so you threaten to win in two directions simultaneously, forcing the opponent into an impossible block
- Always check if you can win on this move before doing anything else
- Always block the opponent if they have two in a row — missing a block means instant loss
- Against the Hard AI, play perfectly from the start (center → corner strategy) to secure a draw
Features
- Three AI difficulty levels: Easy, Medium, and unbeatable Hard (minimax)
- Clean 3×3 grid with clear X and O markers
- Win/loss/draw detection with instant visual feedback
- Quick restart for rapid rematches
- Responsive design for both desktop clicks and mobile taps
- Perfect for learning strategic thinking fundamentals