**Game Theory and Tic Tac Toe**

The game of Noughts and Crosses or Tic Tac Toe is well known throughout the world and variants are thought to have been played over 2000 years ago in Rome. It’s a very simple game – the first person to get 3 in a row wins. In fact it’s so simple that it has been “solved” – before any move has been played we already know it should result in a draw (as long as the participants play optimal moves).

The way to solve Noughts and Crosses is to use combinatorial Game Theory – which is a branch of mathematics that allows us to analyses all different outcomes of an event.

This is the start of the game tree for Noughts and Crosses. We can expand this game tree to cover every possible outcome for the game. Once this complete tree is drawn, any participant can work through this tree to see what is their optimal move at any one time from any position.

An upper bound for the number of positions and number of different games is given by:

3^{ 9}= 19,683. This is the total number of possible game positions in a 3×3 grid – as every square will either be a O, X or blank.

9! = 362,880. This is the total number of ways that positions can be filled on the grid. (First you have 9 choices of squares, then there are 8 choices of squares etc). This counts each X and O as distinct from other X and Os.

9 choose 5 = 126. This is the number of *different* combinations of filling the grid with 5 Xs and 4 Os.

However the analysis of this game tree can be significantly simplified by realising that many different positions are simply reflections or rotations of each other. By looking only for distinct positions (positions that are isometric under refection and rotation) we can, for example, see that there are actually only three distinct starting moves – as shown in the diagram above.

James Grime from Numberphile takes us through how to answer a related question, “*How many different ways are there to completely fill a Noughts and Crosses board with 5 Xs and 4 Os – not including rotations and reflections?” * The solution above is a little complicated (it makes uses of Group Theory) but it is an excellent introduction to some uses of higher level mathematics.

This somewhat horrendous looking graphic actually contains the solution to playing Noughts and Crosses. You can use it to always achieve the optimal outcome for X. It works as follows:

1) The big red X in the top left hand corner represents your best first move. So you make this move first.

2) Next, you see what your opponent does and choose the grid with the big black O in the position they have chosen.

3) This new grid will have a big red X – this is your next optimal move.

4) You then remain in your subsection of the larger grid – and repeat the process.

If you liked this you might also like:

Game Theory and Evolution – do nice guys always finish last?

Knight’s Tour – an exploration of this 1000 year old mathematical puzzle.

## 3 comments

Comments feed for this article

March 2, 2015 at 12:23 pm

scootThis graphical solution to noughts and crosses is excellent. Have you considered removing the redundant isometric reflection and rotation solutions? Most users (that have made it this far in search of the answer) will easily be able to adapt the theory and follow the solution charts within the respective sub-grid as play progresses.

November 30, 2015 at 12:32 pm

hannahi’m not sure if you meant 9 raised to the 3rd power or 3 raised to the 9th power but 9 raised to the 3rd power is 729, whilst 3^9 is 19,683

November 30, 2015 at 6:59 pm

Ibmathsresources.comWell spotted – it should be 3^9 – I will change it!