Trick-Tac-Toe

Two robots play a game of tic-tac-toe. They choose their moves randomly. Let E E denote the expected number of moves it would take for the robots to finish a game. Find 1000 E 1000E rounded to the nearest integer.

Note: A move is defined as the action of one of the robots placing one X or one O. The game finishes after 9 9 moves no matter the result.


The answer is 7626.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Mark Hennings
Aug 23, 2019

For simplicity, let the robots play all nine moves. This means that there are 9 ! 9! games that can be played, all equally likely. Then consider the first stage when each game is resolved (after anything between 5 5 and 9 9 moves).

For the game to be resolved at the 5 5 th move, player X must fill a winning line in moves 1,3,5. There are thus 8 × 3 ! × 6 ! = 34560 8 \times 3! \times 6! = 34560 games in which this happens.

For the game to be resolved at the 6 6 th move, player O must fill a winning line in moves 2,4,6, while player X cannot have filled a line in moves 1,3,5. There are 8 × 3 ! × 6 ! = 34560 8 \times 3! \times 6! = 34560 games in which a winning line is filled in at moves 2,4,6, and there are 6 × 2 × 3 ! × 3 ! × 3 ! = 2592 6 \times 2 \times 3! \times 3! \times 3! = 2592 games in which a winning line is filled in in both moves 1,3,5 and 2,4,6 (the lines must be either both horizontal or both vertical, so there are 6 choices for O's line and then 2 choices for X's line). Thus there are 34560 2592 = 31968 34560-2592=31968 games that are resolved at the 6 6 th move.

For the game to be resolved at the 7 7 th move, player X must complete a line with either moves 1,3,7 or 1,5,7 or 3,5,7, and player O cannot have completed a line at moves 2,4,6. Since it is not possible in these circumstances for player X to complete a line in moves 1,3,5, we deduce that there are 3 3 times as many games that complete at the 7 7 th move as complete at the 6 6 th. Thus there are 3 × 31968 = 95904 3 \times 31968 = 95904 games that complete at the 7 7 th move.

For a game to complete at the 8 8 th move, player O must complete a line at moves 2,4,8 or 2,6,8 or 4,6,8 (and therefore not at 2,4,6), while player X has not completed a line by then. There are 2 × 3 ! × 6 ! × 3 = 25920 2 \times 3! \times 6! \times 3=25920 games in which this is done by completing a diagonal line (there are 2 line choices and 3 move combinations in which the line can be completed, and X cannot certainly not complete a line) and a further 6 × 9 × 3 ! × 4 ! × 2 ! × 3 = 46656 6 \times 9 \times 3! \times 4! \times 2! \times 3 = 46656 games in which this is done by completing a horizontal or vertical line (there are 6 choices for the winning line, 9 configurations of X's four plays that do not complete a line, and 3 move combinations in which the winning line can be completed). This means that there are 25920 + 46656 = 72576 25920+46656=72576 games that are resolved at the 8 8 th move.

All other games are resolved at the 9 9 th move. There are 127872 127872 such games.

Thus the expected number of moves until resolution is E = 5 × 34560 + 6 × 31968 + 7 × 95904 + 8 × 72576 + 9 × 127872 9 ! = 3203 420 \begin{aligned} E & = \; \frac{5 \times 34560 + 6 \times 31968 + 7 \times 95904 + 8 \times 72576 + 9 \times 127872}{9!} \;= \; \frac{3203}{420} \end{aligned} and hence 1000 E = 7626.19 1000E = 7626.19 , making the answer 7626 \boxed{7626} .

to finish game at 5th move shouldnt a factor of 9 be also multiplied , coz there are initially 9 options to choose the first x

Dhruv Aggarwal - 1 year, 9 months ago

No. We have 8 choices for the winning line, 3! choices for the order those three squares are filled,and 6! choices for the other six squares.

Mark Hennings - 1 year, 9 months ago

ohh ok thanks a lot understood. Nice solution

Dhruv Aggarwal - 1 year, 9 months ago

@Sam Zhou , After 1,2,3,or 4 moves, how the game will be finished is difficult to understand. So 9! games can be played is the wrong assumption. I do not agree with this answer.

Winod DHAMNEKAR - 1 year, 8 months ago

Log in to reply

A game of tic-tac-toe will finish, in the ordinary sense, after 5,6,7,8 or 9 moves. However, if you let the players play to the end, then there are 9 ! 9! different games, but more than one of these games will correspond to one of the standard games. For example, consider a standard game where X wins on the fifth move. In my interpretation, there are 4 ! = 24 4! =24 games which all start with the same five moves that lead to X winning, and this means that the probability of a specific five-move game is 24 24 times greater than the probability of any one nine-move game.

I never say that the game finishes in less than 5 moves. I count the number of ways that a game ends in 5,6,7,8,9 moves, and use those numbers to calculate E E . You will note that my counts of games resolved after 5,6,7,8,9 moves add up to 9 ! 9! .

Mark Hennings - 1 year, 8 months ago

@Mark Hennings , For the game to be resolved at the 5th move, The player X must fill a winning line in 1,3, 5 moves. Thus there are 8 × 3 ! × 6 × 5 × 24 8\times 3!\times 6\times 5 \times 24 games in which this happens. (I don't understand why 1440 is multiplied by 24(4!)?. I think it is multiplied because total sample space is multiplied by 24(4!) ) Okay. For the game to be resolved at the 6th move, player O must fill a winning line in moves 2,4,6, while player X could not fill a winning line in 1,3,5 moves. Now there are 6 3 4 2 3 8 6*3*4*2*3 * 8 =3456 - 432*2 =2592 *6=15552 games in which player O can fill a winning line. You have calculated 31968 games. Again, 432 *6 =2592 games are deducted from 34560 games. Would you explain this computations in a easy to understand and step by step manner?

Winod DHAMNEKAR - 1 year, 8 months ago

Log in to reply

Your formula for 5 5 moves, 8 × 3 ! × 6 × 5 × 24 8 \times 3! \times 6 \times 5 \times 24 is the same as mine, 8 × 3 ! × 6 ! 8 \times 3! \times 6! , so we have no problems there. I multiply by 4 ! = 24 4!=24 to allow for all the orders of the four plays after the game has been resolved at the fifth move.

As for 6 moves, you seem to be assuming that O has filled a horizontal or vertical line, when she could have filled a diagonal (in which case X cannot have filled a line at move 5. My argument goes through the cases carefully. Have another look.

If nothing else, my numbers can be confirmed by a simple computer search.

Mark Hennings - 1 year, 8 months ago

@Mark Hennings, I agree with your answers for 5,6 7 moves. But there is a difference between my answer and your answer for computations of number of games in 8 moves to finish the game. I agree with your answer for diagonal winning lines which is 25920 moves. But to finish horizontal and vertical winning lines, my answer for (2,4,8) move is 6 3 5 2 3 1 2 1 = 1080 6 = 6480 2 = 12960 6*3*5*2*3*1*2*1=1080*6=6480*2=12960 , for (2,6,8) move answer is ( 6 3 5 1 3 2 1 1 = 540 6 = 3240 ) (6*3*5*1*3*2*1*1=540*6=3240) and (4,6,8)move is 4320 6 = 25920. 4320*6=25920. So the total number of games are 25920 + 25920 + 3240 + 12960 = 68040 25920+25920+3240+12960=68040 games. Now, what is wrong with these answers?

Winod DHAMNEKAR - 1 year, 8 months ago

Log in to reply

There must be the same number of (2,4,8) winning games as (2,6,8) winning games or (4,6,8) winning games.

In each one of these, O must play three moves on a line and one move off that line, with one of the on-line moves being at stage 8. At the same time, X cannot score a winning line in his 1,3,5,7 moves. We are counting the cases where the winning line is horizontal or vertical, and it is each to check that there are 4 possible sets of moves that X can have made (around O's winning line).

Now X's moves are determined in this calculation by the four moves that O eventually makes, and the order O makes them in does not matter. Thus it cannot make a difference to the number of winning games if O makes his offline move at move 2, 4 or 6. Your counting thinks that it does, which is wrong.

Mark Hennings - 1 year, 8 months ago

this would be right if all 9! games were possible, but some of these games must end early

Mike Pannekoek - 1 year, 8 months ago

Log in to reply

otherwise, shouldn't the answer be 9000?

Mike Pannekoek - 1 year, 8 months ago

Log in to reply

Instead of stopping a game when the first line is drawn, consider playing all nine moves. This may seem pointless, but it means that all 9 ! 9! moves are equally likely. If we consider a game that ends (in the ordinary sense) with a line being drawn at the 5th move, then there are 4 ! = 24 4! = 24 of these fully completed games that all correspond to that 5-move game, and this means that the probability of a 5-move game is 24 24 times more likely than any specific 9-move game.

This method of allowing all 9 moves to be made makes it easier to count the number of games, and hence calculate probabilities.

Mark Hennings - 1 year, 8 months ago

@Mark Hennings, I agree with your final answer 7626. Your answer is correct.

Winod DHAMNEKAR - 1 year, 8 months ago

1 pending report

Vote up reports you agree with

×

Problem Loading...

Note Loading...

Set Loading...