Sunday, October 31, 2010

Naughts and Crosses

Owing to a debate at home regarding the age old game of Naughts and Crosses I decided to do a statistical analysis of the game itself. My initial premise was that the person making the first move is at an advantage and the analysis seems to validate this. Admittedly, I just analyzed the first six moves as most games are decided by that time (truth is I got lazy after 6 rounds of iteration :-) )
Maths Alert:

If you are easily nauseated by mathematical models and concepts or are below 100 years of age then please stop reading here.

Since you have not stopped reading I sincerely pity you but anyways here are the mundane details

1) The first question to be answered of course is how many moves are possible in the game itself. Simple math tells us that the number of ways two symbols (X and O) can be arranged in 9 positions is given by 2^9 which is 512. As usual, simple maths is not sufficient as we have to take into account the rules of the game which says that the symbols "X" and "O" must be placed alternately thus invalidating many of the combinations calculated by the mentioned method. I looked at it from a different perspective and realized that the game would involve 5 "X"s and 4 "O" upon conclusion. Thus the number of ways in which 5 "X"s can be placed in 9 places is 9C5. This is 9!/(5!*4!) = 126. The remaining 4 positions can be filled by 4 "O"s in 1 way. Thus the total number of combinations possible is 126

2) Looking at the layout, it becomes apparent that there are 8 possible routes that spell victory (Figure 1). Thus the possibility that a "X" or "O" is placed on a path that may lead to victory is 8/126 = 0.06


Figure 1

3) Now the fun part :-).
For each possible moves there is a possibility that the placed symbol may lie on a number of "success" paths. Looking at the best case and worst case scenarios in each case we come up with the following:
For the first move by Mr "X" he can opt to put an "X" in positions that put the symbol on a path that is common to 4, 3 or 2 success paths. Taking the best case and worst case scenarios which look like Figure 2 we end up with probabilities of 0.24 (4*0.06) or 0.12 (2*0.06)








Figure 2

4) Now Mr "O" also has best case and worst case scenarios depending on what Mr "X" has done and we end up with the following scenarios (Figure 3)







Figure 3
The corresponding best case and worst case probabilities are therefore 0.18 and 0.06

5) Repeating this iteratively for 4 more moves we end up with the following scenarios (Figure 4)






Figure 4

The following table presents the Best Case and Worst case probabilities for each move and then sums up the probabilities for Mr "X" and Mr "O". The average overall probability considering equal weightages for Best case and Worst case scenarios is then calculated.

















6) My conclusions
a) The person beginning first has a 28.5% chance of winning
b) The person going second has a 24.5% chance of winning
c) Overall there seems to a 47% chance of a draw

NOTES: Please find below some of the answers to the questions that this blog article may prompt you to ask me.

1) Yes, I have a life
2) I do have a job
3) There was no point in doing this
4) You shouldnt bet money on this analysis
5) Oh Yeah?
6) Same to you.

:-)

Cheers
Sam

4 comments:

Tatha said...

Aap Gyani hain, antaryaami hain , budhiman hain, shaktiman hain balke mein to kehta hoon aap purush hi nahi ho......

SRAVAN said...

That you'd make so much out of Vaishnav's "Tic-Tac-Toe" is a bit unnerving to me :). I never intended to think beyond the 9 squares on his board

Kandarp said...

Haha..nice!
I had never thought about the mathematics of the game :)

Was just wondering : The mere fact that the person starting gets 5 chances versus 4 for his opponent makes it unevenly balanced in the first person's favour (at the end of the game, there are always more X's than O's). So, intuitively the probability should be higher ?

Aniket Bhalerao said...

I really cant believe that you get time to analyse all this after the 9.15 on dashboard..
hehe..