# TicTacToe with considerations of symmetry

It is not difficult to determine the number of possible games of tic toe, but what about when rotationally symmetric positions are considered equal? Please do not simply give me the number, I would like the intuition of how it is found. IMPORTANT: I am more talking more about arrangements of x's and o's in a 3X3 grid than actual tictactoe games, thus when somebody "wins" the game it continues.

• tell us how do you determine the total number of possible games, so that we can enhance YOUR answer – Thanos Darkadakis Dec 20 '13 at 2:31
• After the first move, of which there are 9 possibilities, there are 8 possibilities for the second move, so 9*8 positions on move 2. There are seven possible turn 3 moves, leading to 9*8*7 positions, and the pattern continues so that eventually there are 9! games. – Platonix Dec 20 '13 at 2:38
• not exactly. games can end on 5th, 6th, 7th, 8th or 9th move. – Thanos Darkadakis Dec 20 '13 at 2:39
• here is an explanation: se16.info/hgb/tictactoe.htm .There is also a link inside the link... – Thanos Darkadakis Dec 20 '13 at 2:42
• Sorry, read my edited question. You are quite correct of course, but I am more interested in the problem of symmetry than the games that "end" – Platonix Dec 20 '13 at 2:53

I'll use Burnside's method: count the number of invariant patterns for each rotation, and average that number over all rotations to get the number of distinguishable patterns.

I assume we're counting patterns of $5$ Xs and $4$ Os. If you're not allowing reflections, there are $4$ rotations of the square in the plane: the identity, $90^o$ degrees either way, or $180^o$.

For the identity rotation, all $\binom94=126$ patterns are invariant.

For a $90^o$ rotation there are $3$ orbits, one of size $1$ (the center) and two of size $4$ (the four corners or the four sides). Since we have $4$ Os, we have to put them in the four corners or the four sides: $2$ invariant patterns.

For the $180^o$ rotation, there is one orbit of size $1$ and there are four orbits of size $2$, consisting of a pair of opposite cells. The Os have to fill two of the size $2$ orbits; the number of invariant patterns is $\binom42=6$.

Thus the number of distinguishable patterns, allowing rotations in the plane but not reflections, is $\dfrac{126+2+2+6}4=34$.

Suppose you also allow the $4$ reflections as symmetries. Each reflection has three orbits of size $1$ (a cell on the axis of reflection) and three orbits of size $2$ (two mirrored cells). The number of invariant patterns for four Os is $\binom30\binom32+\binom32\binom31=12$, and so the number of distinguishable patterns is $\dfrac{126+2+2+6+12+12+12+12}8=23$.

The following MSE post computes the cycle index for the symmetries of an $N\times N$ board, $N$ odd or even, so that we may apply the Polya Enumeration Theorem, which includes Burnside as a special case. For $N$ odd we get that $$Z(H_N) = \frac{1}{8} \left( a_1^{N^2} + 4 a_1^N a_2^{(N^2-N)/2} + 2 a_1 a_4^{(N^2-1)/4}+a_1 a_2^{(N^2-1)/2}\right).$$ Put $N=3$ to obtain $$Z(H_3) = \frac{1}{8} \left(a_1^9 + 4 a_1^3 a_2^3 + 2 a_1 a_4^2 + a_1 a_2^4\right).$$ The substituted cycle index thus becomes $$Z(H_3)(1+z)= 1/8\, \left( 1+z \right) ^{9} +1/2\, \left( 1+z \right) ^{3} \left( 1+{z}^{2} \right) ^{3} +1/4\, \left( 1+z \right) \left( 1+{z}^{4} \right) ^{2}\\ +1/8\, \left( 1+z \right) \left( 1+{z}^{2} \right) ^{4}$$ which is $$Z(H_3)(1+z) = {z}^{9}+3\,{z}^{8}+8\,{z}^{7}+16\,{z}^{6}+23\,{z}^{5}+23\,{z}^{4} +16\,{z}^{3}+8\,{z}^{2}+3\,z+1,$$ so there are $23$ patterns with five cells marked.

I'll look at completely-filled boards with five $X$'s and four $O$'s (say).

I'll assume rotations and reflections are not distinct.

I'll count the number of distinct cases where $O$ occupies each possible number of corners. Call this number $O_{corner}$.

If $O_{corner} = 0$, there are $2$ patterns: one of the $O$'s is in the center, or it isn't. There is at most one vacant side space.

If $O_{corner} = 1$, there are $5$ cases. If $O$ is also in the center, one can fill the two adjacent sides, one adjacent and one "far" side, or the two far sides. If $O$ is not in the center, either an adjacent side or a far side can be blank.

If $O_{corner} = 2$, these two can be in opposite corners, or adjacent corners.

Let's take adjacent corners first. For a second, let's number the squares: upper left is $1$; lower right is $9$. Our two corner $O$'s are in $1$ and $3$. If one of the $O$'s is in the center ($5$) the distinct cases are spaces $2, 4,$ and $8$. If $O$ isn't in the center, the distinct cases for the last two are the pairs of spaces $(2,4), (4,6), (2,8),$ and $(6,8)$. We have $7$ cases.

For opposite corners, if $O$ is in the center, any side square is the same, symmetry-wise. If $O$ is not in the center, the other two $O$'s can be both next to one of the corner $O$'s, one next to each corner $O$ on the same side of the diagonal, one next to each corner $O$ on the opposite side of the diagonal. So $4$ more cases.

Total cases for $O_{corner} = 2$ is $11$.

For $O_{corner} = 3$, the fourth $O$ is on the side in between two corner $O$'s, on the side not between two corner $O$'s, or in the center. That's $3$ cases.

For $O_{corner} = 4$, that's all she wrote ($1$).

So, $22$ cases. I think I got them all.

If you don't want to consider any of the symmetries I've done, or if you want to take all different numbers of $X$'s and $O$'s, then you can go through the same exercise and determine as you go along which ones are distinct.

• I got $23$ patterns using Burnside. Took me a while to figure out which one you missed. With $O_{corner}=1$ and $O$ in the center, there are two ways to fill one adjacent and one far side. – bof Dec 20 '13 at 4:57