← Ultimate tic-tac-toe against the computer

Ultimate Tic-Tac-Toe Strategy: Where Your Move Sends the Computer

The numbers on this page come from games simulated with the page's own code: the rules and the computer's Monte Carlo search, copied unchanged. The levels are limited by time, so they were simulated at a fixed number of random games per move — 75,000 for Normal, 270,000 for Hard, 740,000 for Expert, about what each level finishes from the opening in Chrome on a recent Mac. Each figure gives the number of games behind it.
The short answer

In ultimate tic-tac-toe the cell you choose matters less than the board it sends your opponent to, and the board worth fighting for is the centre one: between two equal copies of the computer, whoever won the centre board won the game 51% of the time, against 39% for an edge board. Simple rules do nothing against this computer — none of the six we tried won a single game out of 100 against Normal — while a player who looks as far ahead as Normal wins about half. No level repeats itself, so there is no fixed winning line to learn.

Every move is an address

Number the cells of a small board 1 to 9, left to right and top to bottom, and number the nine small boards the same way. A move in cell 3 of any board sends your opponent to board 3, the top-right one. So each move has two meanings: where your mark goes, and where the computer's next mark must go.

Cell numbers inside any small board. The number of the cell you play is the number of the board your opponent must play in next.
A small board where the computer (O) has two in a row. Any move of yours in a cell with the same number as this board sends it here, and it completes the row at 1.

This is the first thing to check, and the simulations show how much it costs to ignore. A player who simply takes a small board whenever it can and otherwise plays at random lost all 100 of its games against Normal, and the games were short: 33 moves on average, counting both sides. Adding one check — never send the computer to a board it can win on the spot — stretched the games to 44 moves. It did not turn them into wins: 99 losses and one draw in 100. The check is necessary, not sufficient.

Winning small boards is not the same as winning the game. That careful player took the first small board in 95 of its 100 games and still lost 99 of them; at the end the computer held 4.2 boards on average, the human 2.9. The computer gives up a board readily when doing so sends you somewhere useless and leaves it the next address it wants. The page's own article says the same in theory; here it is in numbers.

What the centre is worth, measured

The big board is a tic-tac-toe board, so the same count applies: the centre board lies on four of the eight winning lines, each corner board on three, each edge board on two. The simulations agree, whichever way the question is asked:

MeasureCentre boardCorner boardEdge board
Winning lines through it (exact)432
X wins after a first move there, random play*43–45%42%40%
Its owner won the game, computer vs computer51%43%39%

* Both sides play random legal moves to the end, 40,000 games for each kind of first move. Overall, random play gives X 41.3%, O 36.6% and a draw 22.1% (100,000 games). “Computer vs computer” is 100 games of Normal against Normal; each kind of board was won by someone in 77–79% of them.

The computer's own search, given four times Expert's budget — three million random games — spends 35% of them on the centre cell of the centre board, six times as many as on any other first move, and scores it at 56% for the player who moves first (a draw counting as half a win).

One trap: the centre cell is not the centre board. A move in cell 5 sends your opponent to board 5. A rule that preferred the centre board and, inside any board, the centre cell handed the centre board to the computer in 99 of 100 games against Normal. Fight for board 5 by playing in it, and be careful about how often you send the computer there.

The send-back opening, and why it fails here

A well-known opening tries to exploit the send rule: take the centre cell of the centre board, and every time your opponent has to answer there, reply with the centre cell of the board he sends you to. That sends him straight back to board 5, again and again, while you collect centre cells all over the big board.

Against this computer it backfires at once. Your mark in board 5 sits alone, and the computer gets to place mark after mark there for free.

The centre board in a real game against Normal after five moves of the send-back opening: X opened in its centre, O has two corners of the bottom row. Sent back once more, O completes the row at 1.

In 100 games against Normal the computer won the centre board in all 100, typically with its third move. From then on, every centre-cell move sends it to a closed board and gives it a free move. The opening lost all 100 games.

Free moves: how this page handles a closed board

A small board closes when someone wins it or when it fills up with no winner. Its empty cells are out of play for good (they turn grey), and a full board with no winner counts for nobody. If your move points at a closed board, your opponent may play in any open board; when that happens to you, the page lights up every open board.

One case is easy to miss: the board you have just closed counts. Win the top-right board with its top-right cell, and your move points at that same board, now closed — a free move for the computer.

X completes the top row of the top-right board with its top-right cell (ringed). The board closes, and because the move points at board 3 itself, the computer may play in any open board.

Free moves are part of almost every game. In random play 99.4% of games had at least one, 7.5 per game on average, the first usually after about 36 moves. Between two equal copies of the computer each side got about three per game, and the side that got more of them won 74% of those games when it was X and 47% when it was O (losing only 2 of 36). That is a link, not proof that the free move itself decides the game: free moves appear when boards close, and the side that closes them is often already winning.

Avoiding them is not a strategy by itself. Adding “never give a free move when you can avoid it” to the safety rule changed nothing against Normal: it lost all 100 games, just as the safety rule alone lost 99 and drew one.

How each level plays, and what beats it

All three levels run the same Monte Carlo search; the only difference is how many random games it plays out before the clock stops it. Here is how simple ways of choosing a move did against each level (you play X and move first; ties broken at random):

Your rulevs Normalvs Hardvs Expert
A random legal move0% (100)––
Take a small board whenever you can, otherwise random0% (100)––
Never let the computer win a small board next move; otherwise take boards0% (100)0% (40)0% (20)
The same, and never give a free move0% (100)––
The same, and prefer the centre board and centre cells0% (100)––
The send-back opening, then the safety rule0% (100)––
The page's own search, 15,000 random games a move (a fifth of Normal)9% (100)––
The page's own search, 75,000 random games a move (as much as Normal)48% (100)25% (40)0% (20)
The page's own search, 270,000 random games a move (as much as Hard)63% (40)33% (24)–

Wins for you; the number of games in brackets. A dash means not simulated. Draws are not counted as wins: the safety rule drew one game in 100 against Normal; the search with 75,000 games drew 31% against Normal, 43% against Hard and 30% against Expert.

The table says something plain: against this computer, rules of thumb about single moves are worth nothing, and looking further ahead is worth everything. A search as deep as Normal wins about half its games against Normal, and that is with the first-move advantage — the computer answering itself as O won only 21% of those games. Give the search a fifth of that and it wins 9%; give it as much as Hard, and it beats Normal in 25 of 40 games. Against Hard itself, that equal search won 8 of 24 games, lost 6 and drew 10: the deeper both sides look, the more often the game ends level.

No level repeats itself. The search picks which line to try next and plays out every game with random moves, so the same position can get different answers. After your centre opening, 200 searches at Normal's budget produced seven different replies, the most common one (the bottom-right corner) only 29% of the time; at Expert's budget 40 searches still produced four, one for each corner. A fixed list of moves that beats it once will meet a different game next time, so this guide has no recipe to learn by heart.

Your device matters. The level sets a thinking time, not a strength. The line under the board shows how many random games the computer finished for its last move. Our figures assume a desktop browser; on an old phone the computer finishes fewer and plays weaker, though still far beyond simple rules.

The rules of thumb, in order of value

  1. Before every move, look at the board it sends the computer to. If it can win that board at once, play somewhere else, even at the cost of a board of your own.
  2. Win the game, not boards. Three small boards in a line decide it; boards off your lines are worth little, and the computer gives them away on purpose.
  3. Fight for the centre board by playing in it, and count how often your moves send the computer there.
  4. Before you close a board, check what your move points at: winning a board can hand the computer a free move.
  5. Look two moves ahead, not one: where you send it, and where its best answer sends you back.

Against Normal, the first four rules only make the game last longer: none of the rule sets we tried won a single one of 100 games. The fifth is what counts — it is the difference between 9% and 48%.

Questions and answers

What is the best strategy in ultimate tic-tac-toe?

Think about where each move sends your opponent before you think about the cell itself: never send them to a board they can win at once, fight for the centre board, and play for three boards in a line rather than for as many boards as possible. Against the computer here, looking two moves ahead matters far more than any fixed rule.

What happens if you are sent to a board that is already won?

On this page you may play in any open board: a board that has been won, or filled with no winner, is closed for good. That includes the board just closed by the move that sent you there.

Is it better to go first in ultimate tic-tac-toe?

Yes, by every measure we took. In 100 games between two equal copies of this computer, the first player won 48% and the second 21%, with 31% drawn; even in purely random play the first player wins 41% against 37%. The game has not been solved, so this is an observation, not a proof.

Is the centre the best first move?

The centre cell of the centre board is the computer's own favourite: given three million random games to think, it spends a third of them on that move, six times more than on any other, and scores it at 56% for the first player. In random play, a first move in the centre board gives X 43–45%, against about 40% for an edge board.

Can you beat the computer at ultimate tic-tac-toe?

Yes, but not with simple rules: none of the six we simulated won a single game out of 100 against Normal. What wins is calculation: a player who looks as far ahead as Normal beats it about half the time. Hard and Expert simply look further.

Does the computer always play the same way?

No. All three levels choose moves from tens or hundreds of thousands of random playouts, so the same position can get different answers: after the centre opening, Normal chose among seven different replies across 200 searches. There is no fixed sequence of moves that always wins.

Play ultimate tic-tac-toe against the computer →
Where to go from here
To cite this page: “Ultimate Tic-Tac-Toe Strategy: Where Your Move Sends the Computer”, You vs Computer, https://youvscomputer.com/games/ultimate-ttt-strategy.html