← Nesim Apps

Tic-Tac-Toe: A Solved Game, an Early Computer and Its Variants

By Nesim Razon, independent Android developer · 2026-11-10

Tic-Tac-Toe is the first game most of us ever play, and it is also one of the first games a computer ever played. It is tiny, it is solved, and yet it has a surprising number of cousins. Here is what we can say for sure about its past, its maths and its variants.

One game, many names

In the United Kingdom and many other places the game is called noughts and crosses. In the United States it is Tic-Tac-Toe, in Turkey it is often called XOX, in Spanish-speaking countries tres en raya and in Brazil jogo da velha. The rules are the same everywhere: two players take turns marking a 3x3 grid, one with X and one with O, and the first to complete a line of three wins.

A line can be a row, a column or a diagonal. If all nine squares are filled and nobody has a line, the game is a draw. Those few lines of rules are all there is, which is exactly why the game works as a first lesson in strategy for children.

OXO: an early computer game in 1952

One of the first video-style computer games was a version of noughts and crosses. In 1952 Alexander S. Douglas, a student at the University of Cambridge, wrote a program called OXO for the EDSAC computer. It was part of his PhD work on how people interact with computers, and it let a human play against the machine, with the board shown on a small display.

It is a good reminder that Tic-Tac-Toe is a perfect test case for a young machine. The rules are short, the board is small and the program can check every possibility. That is also why the game appears so often in early computing stories and in teaching examples about search and decision making.

Why the game is solved

A game is called solved when we know the result with perfect play from both sides. For Tic-Tac-Toe, the result is a draw. If both players never make a mistake, nobody wins. A player who follows the right moves can always avoid defeat, whether they start or not.

This is not a guess or a rule of thumb. It can be proved by checking every possible line of play, and a computer does it in a blink. The idea behind such a check is called minimax: assume your opponent always picks the reply that is worst for you, and choose your move so that the worst case is as good as possible.

How small is the game tree?

Counting all the ways a game can unfold gives 255,168 possible complete games if you stop when someone wins. If you count only the different board positions that can really appear, there are 5,478. Once you treat rotated and mirrored boards as the same position, the number becomes much smaller still.

For a modern computer these are tiny numbers. For a human they are small enough to learn by heart, which is why people stop finding the game exciting once they have mastered the opening. It also explains why a perfect computer opponent is easy to build, while games like chess or Go need far more clever methods.

From 3x3 to m,n,k games

Mathematicians generalise the idea. An m,n,k game is played on a board with m columns and n rows, where the first player to get k marks in a row wins. Tic-Tac-Toe is the 3,3,3 game. Changing the three numbers gives a whole family of games.

A neat result about this family is the strategy-stealing argument. In these games an extra mark never hurts you, so the second player cannot have a guaranteed winning strategy. At best the second player can force a draw, and often the first player has the edge. Even this simple idea says a lot about fairness in turn-based games without telling you the actual best move.

Famous cousins

Playing it against a computer

A good Tic-Tac-Toe app can show you what perfect play looks like. In our Tic-Tac-Toe app you choose between three difficulties. Easy takes an immediate win about half the time and otherwise picks a square at random. Medium blocks your winning moves and takes its own chances, but it can be tricked with a fork, a move that creates two threats at once. Hard plays perfectly with the minimax idea and never loses.

That means you cannot beat Hard, but you can draw with it, and that is a real achievement. The starting player changes from game to game, so you practise both sides. If you want to learn how to get those draws and how to set traps against weaker players, our strategy guide goes through the moves step by step.

What the little game teaches

Tic-Tac-Toe is a tiny laboratory for ideas that matter far beyond it: planning ahead, spotting threats, forcing the opponent's reply and understanding that some games end in a draw when both sides are careful. Learning that a draw is a good result can be a first step toward thinking strategically.

Try making your own variants too. Change the board size, require four in a row, or forbid the centre on the first move. Rule tweaks turn a solved game into something fresh, and that is how many of the games above began.

Try it yourself

A fun experiment: play ten games against Easy, then ten against Medium, and note how often you can set up a fork. Then try Hard and count your draws. Watching how the three levels respond to the same opening shows, better than any text, how a perfect player thinks.

Frequently asked questions

Who invented Tic-Tac-Toe?

Nobody knows for sure, so we do not claim an inventor. What is documented is that Alexander S. Douglas wrote the computer game OXO for the EDSAC in 1952.

Is Tic-Tac-Toe a solved game?

Yes. With perfect play from both players the game always ends in a draw.

Can you always win by going first?

No. Going first helps, but a player who never makes a mistake can always at least draw, so perfect play from both sides leads to a draw.

How many games of Tic-Tac-Toe are possible?

255,168 complete games if play stops when someone wins, using 5,478 different reachable positions.

Can I beat the computer in the app?

You can beat Easy and, with a clever trap, Medium. Hard plays perfectly and never loses, so the best result against it is a draw.

More from the blog