-Up to-Home/Maths
-Site Map|-Text version

- Notes on Tic-Tac-Toe (Noughts and Crosses)

  -- Fred Curtis

[Normal 3 x 3 Tic-Tac-Toe] [2D Configuration counts] [3D 3 x 3 x 3 Tic-Tac-Toe] [Symmetries] [Source Code] [Chronology] [References]


Normal 3 x 3 Tic-Tac-Toe

I'd heard that the first player (say X) in a normal 3x3 tic-tac-toe game could "force a draw", which I took to mean "can't always force X-wins, but can force X-wins or a draw", since the usual goal for each player is to win.

So, the questions arose:

To answer these questions, I wrote a program (ttt-2d-forced.pl) to analyse force moves in tic-tac-toe. The answer, which surprised me, was that either player can force any one of the outcomes:So, for example, if one player attempts to force a draw, the other player can force someone to win. If player X attempts to lose, the other player can thwart that goal by forcing X-wins or Draw.

2D Configuration counts

Configurations in 2D 3x3 Tic-Tac-Toe ignoring symmetries
DepthNo. of Configurations
TotalNon-TerminalTerminal
01(empty board) 10
1330
212120
338380
41081080
517415321
620418321
71539558
8573423
915(ties) 312
Total765630135
Configurations in 2D 4x4 Tic-Tac-Toe ignoring symmetries
DepthNo. of Configurations
TotalNon-TerminalTerminal
01(empty board) 10
1330
233330
32192190
4141314130
5551455140
620122201220
75021549935280
8112379111737642
91795101745684942
102456902389206770
1124569022540420286
1219331817727616042
131104528945420998
1441870339007970
151048967153774
161059(ties) 688371
Total1217976113590182075
Configurations in 2D 5x5 Tic-Tac-Toe ignoring symmetries
DepthNo. of Configurations1.5GHz Pentium4 RH Linux 7.2
TotalNon-TerminalTerminalRun TimeCPU TimeStorage used
1660   
285850   
39049040   
4966496640   
566859668590   
64438504438500   
7210569521056950   
89469965946996506m6m0.1Gb
93218817032180742742831m30m0.4Gb
10102962268102938806234622h011h50m1.2Gb
112573893922570400903493025h56m5h24m3.0Gb
1259987256059905884081372014h50m13h25m7.3Gb
13??????

3D 3 x 3 x 3 Tic-Tac-Toe

This game is can be trivially won by the first player by playing a piece in the central space. I'd heard that a draw was impossible because there are too many winnable lines (49) for the first player to place their 14 pieces without winning. In fact, the figures computed below indicate that the game must terminate after 26 pieces are played, i.e. after the second player's last piece is played.

Configurations in 3D 3x3x3 Tic-Tac-Toe ignoring symmetries
DepthNo. of Configurations1.5GHz Pentium4 RH Linux 7.2
EstimatedActual TotalNon-TerminalTerminalRun TimeCPU TimeStorage used
001(empty board) 10   
11440   
21431310   
31832542540   
42194251225120   
5168191783417459375   
61233381241621218972265   
764752264428860048843800   
83237609303885928332342056254m4m 
912302916115171729632913188425915m15m0.1Gb
1044290496371473323104972260976101h01m57m0.5Gb
1112548973910480112972876736319243933h15m3h03m1.2Gb
12334639305231884196160769332711148647h24m6h53m2.3Gb
1371708422548623128425710122822913005615h22m14h19m4.0Gb
1414341684507288037833823347363464690471d00h30m23h13m7.0Gb
15233052373111039464474051900026987564452d08h35m2d03h38m16.4Gb
16349578559710901878363933047056968831311d18h58m1d17h22m11.7Gb
17427262684111286487192638053908648433291d14h51m1d12h14m12.1Gb
18474736315670086731815844955054241776816h49m15h31m8.0Gb
194272626841457435053625523973948826569h29m9h39m3.5Gb
203418101473165743273213473141443959593h01m2h53m1.6Gb
2121751554836090325344098745649337951m49m0.4Gb
22118644844511368950741017106279338m8m0.1Gb
2349435351919769176459219123251m1m 
241647845061506723881146791   
2538027194858864384   
2658503381150115   
27417881000   

Note on estimates - the number ways of arranging p1 pieces of player 1 and p2 pieces of player 2 in a board with n slots is: (number of ways of placing p1 pieces in n slots) * (number of ways of placing p2 pieces in remaining slots) = [n choose p1]*[(n-p1) choose p2) = [n!/(p1!*(n-p1)!)]*[(n-p1)!/(p2!*(n-p1-p2)!)] = n!/(p1!*p2!*(n-p1-p2)!). If we assume that almost none of these configurations has any self-symmetry (see Symmetries below), then we can divide by a factor of d!*2d where d is the number of dimensions. For a 3x3x3 board, the estimate for a given p1 and p2 is: 27!/(48*p1!*p2!*(n-p1-p2)!).

Symmetries

When using computer programs to investigate tic-tac-toe games, as with many other puzzles, it is convenient to group together configurations which are essentially the same. For example, in the 2D 3x3 game, the first player might place a piece on an edge, and the second player might place a piece in a corner next to the first player's piece. This can be done in 8 ways, all of which can be treated the same (by appropriate rotation/reflection of the board) in terms of further possible moves and outcomes.

A d-dimensional cube has d!*2d distance-preserving symmetries. Imagine one corner of the cube placed at the origin in d-space, with d axes radiating from the origin. Now imagine the origin translated to one of the 2d corners. The d axes radiating from the new corner can be assigned in d! ways to the edges radiating from the new corner.

Number of distance-preserving symmetries of a d-dimensional cube
dNumber of symmetries
22!*22 = 2*4 = 8
33!*23 = 6*8 = 48
44!*24 = 24*16 = 384

Source Code

Chronology

References


-This page
last changed:
20 Jul 2003
[Validate HTML]
-Donate free
food & land
 
-
|Feedback by email
or Web form