Free Converter

Tic-Tac-Toe Online Game

Play the classic Tic-Tac-Toe game online. Challenge a friend or play against the computer with adjustable AI difficulty.

X0
0Draw
O0
Your turn

About Tic-Tac-Toe

Tic-Tac-Toe (also called Noughts and Crosses) is a classic 3×3 grid game where two players take turns marking cells with X or O. The first player to align three of their marks horizontally, vertically, or diagonally wins. With perfect play by both sides, the game always ends in a draw — the game is solved, meaning optimal strategies exist for both players.

Despite the simple rules and solved nature, Tic-Tac-Toe remains popular for casual play and is a foundational example in game theory and AI courses. Computer opponents using minimax algorithms play optimally; against an optimal opponent, the human can at best draw. Against weaker opponents, victory is achievable.

This implementation supports two-player local play and play against an AI. The AI difficulty is configurable: random moves (easy), heuristic-based (medium), or minimax-optimal (hard). At hard difficulty, the AI never loses; at most it draws.

Why Play Tic-Tac-Toe

Quick games (typically under a minute) make Tic-Tac-Toe a perfect short break activity. Five-minute breaks accommodate several games. The simplicity also makes it accessible to children and adults alike.

It is also instructive. Playing against a perfect AI teaches the structure of the game — first player can force a draw with center opening, certain corner moves are preferable, etc. The game theory lessons transfer to more complex domains.

How to Play Tic-Tac-Toe

Mark cells, get three in a row.

  1. Choose mode: Two-player (alternating turns at the same screen) or single-player (against AI).
  2. First player marks X: X traditionally goes first. Click any cell to place an X.
  3. Second player marks O: Then click any empty cell to place an O. Players alternate until the game ends.
  4. Win or draw: First to align three marks in a row, column, or diagonal wins. If the board fills with no winner, the game is a draw.

Common Use Cases

Technical Details

Game state: a 3×3 array tracking each cell's content (X, O, or empty). Win check after each move: scan all 8 lines (3 rows, 3 columns, 2 diagonals) for three identical non-empty marks.

AI: minimax with alpha-beta pruning. The full game tree has 9! = 362,880 leaf nodes (most pruned by symmetry and game ending early). Computing optimal play in browser is instant.

First player advantage: with perfect play by both, X can force a draw against any O strategy and win against suboptimal O. With perfect play by both, the game ends in a draw.

Best Practices

Frequently Asked Questions

Is Tic-Tac-Toe a solved game?
Yes. With perfect play by both, the game always ends in a draw. First player can force a draw against any opponent strategy and win against imperfect play.
What's the best opening move?
Center is strongest. It participates in 4 of the 8 winning lines. Corner is second best. Edge is weakest.
Can I beat the hard AI?
No, if the AI plays minimax-optimal. Best you can achieve is a draw. Against medium or easy AI, victory is achievable.
Are draws normal?
Between two skilled players, yes. With perfect play, every game draws. Wins require an opponent mistake.
Can the AI lose?
Hard difficulty AI never loses. Easy and medium difficulties can lose — easy plays randomly, medium uses simple heuristics that miss some opportunities.
What's the minimax algorithm?
Minimax explores all possible move sequences and picks the one that leads to the best worst-case outcome. For Tic-Tac-Toe, this is computationally trivial.
Is the game saved between sessions?
Most implementations don't save state. Each game is fresh. Some track win counts in localStorage.
Can two people play remotely?
This implementation supports local two-player. Remote play requires a multiplayer server, which most browser-based versions don't include.