โœ•โ—‹ Tic Tac Toe

Get three in a row โ€” horizontally, vertically or diagonally.

0
You (X)
0
Draws
0
Computer (O)
Your turn (X)

About Tic Tac Toe

Tic Tac Toe โ€” also known as Noughts and Crosses โ€” is one of humanity's oldest strategy games, with evidence of similar grid alignment games dating back to ancient Egypt around 1300 BCE. Its rules are learned in minutes, yet it contains genuine mathematical depth. The game is a "solved" puzzle: with perfect play from both sides, it always ends in a draw. Understanding why teaches you the fundamentals of strategic thinking โ€” threat creation, blocking, and the concept of a "fork."

This version features three AI difficulty levels. Easy plays randomly, making it beatable with basic strategy. Medium mixes random and optimal moves. Unbeatable uses the minimax algorithm โ€” a recursive search through all possible future game states โ€” to play perfectly. You cannot beat it, but you can always draw with the right moves.

How to Play

You play as X, the AI plays as O. Click any empty square to place your mark. Players alternate turns. The first to place three marks in a row โ€” horizontally, vertically, or diagonally โ€” wins. If all nine squares fill with no winner, it's a draw. Select your difficulty before starting.

Strategy Tips

Why Tic Tac Toe Is Good for Learning Strategy

Tic Tac Toe is the ideal introductory strategy game because every concept it teaches โ€” positional value, threat creation, defensive blocking, and forking โ€” scales directly to more complex games like Connect Four, Chess, and Go. Children who learn to recognise double threats in Tic Tac Toe apply the same pattern recognition to much harder problems later. It's one of the best tools for teaching logical thinking to any age group.

Frequently Asked Questions

Can I ever beat the Unbeatable AI?
No โ€” it plays perfectly using minimax and cannot lose. The best result is a draw. This is mathematically correct: Tic Tac Toe with optimal play from both sides always ends in a draw.
How many possible games are there?
There are 362,880 possible move orderings. Accounting for symmetry, 138 distinct terminal positions exist โ€” 91 wins for X, 44 wins for O, and 3 draws. Draws require both players to play correctly.
What is the minimax algorithm?
Minimax builds a complete decision tree of all future game states, assigns win/loss/draw values to each, and always picks the move that maximises its own minimum guaranteed outcome. With only 362,880 states, Tic Tac Toe can be solved exhaustively โ€” making the AI provably perfect.