Tic Tac Toe
Tic Tac Toe against the computer. The AI plays a solid defensive game - it blocks your winning moves and tries to set up its own. A draw is the expected outcome against best play.
Your turn (X)
How to use
- You're X, the computer is O. You go first.
- Click any empty cell to place your X. The computer will respond immediately.
- Get 3 of your marks in a row (horizontally, vertically, or diagonally) to win.
- The computer blocks your moves and tries to win. Think two steps ahead!
Related tools:
Tic Tac Toe is played on a 3x3 grid. You and the computer take turns placing your mark, X or O. Get three in a row across, down, or diagonally to win. The computer plays defensively and looks for winning opportunities, so a casual approach will often lead to a draw or loss.
A perfect Tic Tac Toe game between two players who both play optimally always ends in a draw. The game is mathematically solved, which is why it is often used in introductory computer science courses to teach game tree search and minimax algorithms. Against a computer playing optimally, the best you can do is draw. Against a suboptimal opponent, winning requires taking the center first and setting up a two-way threat.
Frequently Asked Questions
Can you beat a computer at Tic Tac Toe?
Against an optimal computer opponent, no. Perfect play always results in a draw. The computer playing here may not be fully optimal, giving you a chance to win.
What is the best first move?
The center square gives you the most potential winning lines from a single position and is the strongest opening move.
How do you set up a guaranteed win?
Create a fork: two separate ways to get three in a row on your next turn. Your opponent can only block one, so you win the other.
How many possible Tic Tac Toe games are there?
There are 255,168 possible games, but only 138 are distinct when you account for symmetry. The game tree is small enough for computers to solve completely.