# Tic-Tac-Toe-Take-Two

by Philip Newman

First, we're going to assume that the game goes on until full, even if someone has already won (this doesn't affect the probability we're after).

There are 9!/5!/4! = 126 final configurations (the 5! is the number of ways the Xs can be arranged, and the 4! is the number of ways the Os can be arranged).

There are 8 ways to win. If X gets three in a row, there are these 8 wins, times the number of ways the other 2 Xs can be placed, which is 6!/2!/4! = 15; 8*15 = 120. However, we count some configurations twice, since X could get two three-in-a-rows. There are 2*6 = 12 ways X can have a diagonal and either a vertical or horizontal; there are 3*3 = 9 ways X can have a vertical and a horizontal; and there is 1 way X can have both diagonals. In total, there are 98 configurations where X has a row.

There are 8*6 = 48 ways for O to get three in a row (the 6 is the number of places for the 4th O).

In order for *both* players to have a row, neither can have a diagonal. There are therefore 6 ways for X to have a row, 2 remaining for O to have a row, and 3 ways for the 4th O to fall. So, there are 36 ways for both to have a row.

So, so far, there are 12 ways for only O to have a row (all diagonals), 62 ways for only X to have a row, 36 for both to have a row, and 16 configurations that are draws.

Now, of the configurations where both have a row, there are 5!4! = 2880 ways to reach these configurations. Consider X's last move. 3 of the 5 Xs are part of X's row, so there are 3*4! ways for X to move such that he completes his row on his last turn. There are still 4! ways for O to move. Therefore, there are 3*4!*4! = 1728 ways for X to finish his row on the last move (and O wins). In order for X to finish on his 4th move, one of the first 3 Xs must be in one of the 2 non-row spaces; there are 3*2*3! ways to do this. There are 3! ways for O to finish his row on his 3rd turn (and O wins); so, the number of ways both happen is 3*2*3!*3! = 216. These are the only two ways O wins if both have a row, so O wins 1944/2880 of these games, and X wins 936/2880 of them.

So, in summary:

X wins: (62 + 36*(936/2880))/126 = 737/1260 (.5849206...) O wins: (12 + 36*(1944/2880))/126 = 121/420 (.2880952...) Draw: 8/63 (.1269841...)