Posted June 2, 2015 By Presh Talwalkar. Read about me , or email me .

Last week two Houston Rockets fans faced off in a game of tic-tac-toe (aka noughts and crosses) during halftime. Each fan had to score a basket in order to place a piece on the board, either an “X” or an “O” (which was a Toyota logo). Who would get three in a row first?

Watch the two play some very unconventional strategies.

Tic Tac Toe Fail During Houston Rockets NBA Game

When two smart people play tic tac toe, the game always ends in a draw. The converse is not true.

Below I summarize the video and explain how you should play tic tac toe optimally.

.

.

"All will be well if you use your mind for your decisions, and mind only your decisions." Since 2007, I have devoted my life to sharing the joy of game theory and mathematics. MindYourDecisions now has over 1,000 free articles with no ads thanks to community support! Help out and get early access to posts with a pledge on Patreon. .

.



Tic Tac Toe Fail

Here were the first four moves: X took center, O took the upper right corner, X took upper left corner, and then O took lower left corner to block. These first four moves were correct strategy.

Now obviously X needs to block, but instead X plays the middle of the bottom row.

So O is ready to win! But instead O decides to block the middle of the upper row.

Now X can still block O. But instead X goes for an attack!

This means O has yet another chance to win by playing the right of the middle row. But instead O decides to block X by playing the first column of the middle row.

And so finally X plays the last spot to end the game.

I am not judgmental and understand they were probably overwhelmed by the moment. Some people have pointed out the players did not have a bird’s eye view to see the entire board. But then again, the emcees had the same view, and they were stunned at how the two were playing, even trying to help them play the right moves.

Perhaps the funniest part of the video is the emcees were clueless about what to do when the game ended in a draw. I mean, tic tac toe is supposed to end in a draw–shouldn’t they have been prepared for this eventuality?

Almost everyone knows how to play tic tac toe. But there are lessons to be learned from analyzing the game in more detail. Let’s explore the optimal strategy.

Tic Tac Toe Strategy

Even though tic tac toe is a simple game, there are 138 possible ways the game can proceed (taking into account rotational and reflection symmetries). This is a large amount of positions to try and memorize.

Almost everyone can figure out the game using basic strategy. You should take the center or a corner to give yourself more attacks. You could complete a 3 in a row any time you can, and if that’s not possible, you should block an opponent’s threat of a 3 in a row. When both players use these simple heuristics, the game will end in a draw.

Tic tac toe has been completely solved by computer. Here is one website where you can figure out the best move(s) for each position: tic tac toe solver.

With perfect play, the game always ends in a draw. The interesting part is that if either player makes even a single mistake, there is a chance to win the game.

The First Player Can Play Anywhere

The first player can actually win following any first move. This is a somewhat surprising result–in Connect Four the only winning first move is to play in the center.

If the first player picks a corner, then the second player has to pick center to maintain the chance of a draw.

X | |

————-

| * |

————-

| |

* = only move to maintain a draw

If the first player picks center, then the second player has to pick a corner to maintain the chance of a draw.

* | | *

————-

| X |

————-

* | | *

* = moves to maintain a draw

If the first player picks an edge, then the second player has to play on the same row or column to maintain a draw.

* | |

————-

X | * | *

————-

* | |

* = moves to maintain a draw

By this reasoning, you could argue that playing a corner is the optimal move for first player. It gives the most number of chances for the second player to mess up.

But using some game theory and psychology, I like to start off playing one of the edge pieces. When you play a corner or the center, people perceive it as a strong move and the second player will always respond with center. And so let’s explore playing an edge first.

Playing Edge

If you start off playing an edge, this is unexpected and perceived as a weak move that can sometimes throw people off. If you play the game enough times, the second player might not see the threat and could play an opposite corner by mistake.

Suppose the second player picks a corner not adjacent to your edge piece. (The same analysis works if the second player picks another edge.)

| | O

————-

X | |

————-

| |

If the second player messes up, you should then take the corner next to your edge in the same row as O’s (this is the corner that is not diagonal to O’s piece).

X | | O

————-

X | |

————-

| |

Then O will have to block your threat of two in a row.

X | | O

————-

X | |

————-

O | |

And then you can take the center to make a double attack.

X | | O

————-

X | X |

————-

O | |

You can make a 3 in a row either in the middle row or on the diagonal, and O cannot block both of them. So you can win this game.

So to summarize: start off playing an edge and hope that second player picks either an edge or a corner not next to your piece. You can then win by picking a corner next to your piece in the same row as their piece.

Even if second player doesn’t do this, you don’t have to worry about losing: using common sense you can always play to a draw too.

Playing Center

When you play center, O can maintain a draw by playing a corner. But what if O makes a mistake and plays an edge? You then have 6 moves where you can respond to win. These are the two empty columns (or two empty rows) left on the board.

* | O | *

————-

* | X | *

————-

* | | *

* = winning move

Wherever you move, you will create a 2 in a row that forces O to block. You can then always create a double attack.

For example, let’s say you pick a corner opposite from O.

| O |

————-

| X |

————-

X | |

Then O has to block in the upper right corner.

| O | O

————-

| X |

————-

X | |

Now you play the upper left corner. This blocks O’s attack, and you create a double attack for the first column and the diagonal.

X | O | O

————-

| X |

————-

X | |

So to summarize: start off playing center and hope that second player picks an edge. You can then win by picking a spot in the two empty rows or two empty columns that remain on the board.

Playing a corner

This is the most popular strategy for the first move. If O does not pick the center in response, you have a chance to win the game.

If O picks an edge, then you need to pick the center. If O picks a corner, however, then you should pick a corner as well.

This is why I personally like playing edge or center as my first move–it’s somewhat easier to memorize what to do if O makes a mistake.

The web comic xkcd has made a guide to winning if you play corner as your first move.

Image CC BY-NC 2.5

You start playing X in the upper left corner. Then you look at the position of O’s move and zoom in on that region. The largest X is your next move, and then you repeat the process to find the optimal move at each step.

In my opinion, this is the least easy strategy to follow. So even though playing corner as X has the most chances to win, I also think it has the most chances to mess up a guaranteed win as well.

Ultimate Tic Tac Toe

There is a nice variation of the game we covered before called Ultimate Tic Tac Toe.

This is a large 3×3 board in which each square also has a small 3×3 board. Your move in a large square determines which small square your opponent has to play, and so on. If you are forced into spot you cannot play, then you can play anywhere.

If you get 3 in a row on a small board, you win that large square. Then you need to win 3 large squares in a row to win the game.

Sound complicated? Here are the rules explained in a video.

Ultimate Tic-Tac-Toe: The Rules

It turns out there is a winning strategy for this game: the first player can always win.

Ultimate Tic Tac Toe: The First Player Has A Winning Strategy

Check out more math videos on my YouTube.

Thanks to Patrons

Alberto Nishikawa

Kyle

You can support me at Patreon.