Tic-Tac-Toe

Author

Eric W. Weisstein
January 27, 2011

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Games/Tic-Tac-Toe.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Tic-Tac-Toe.html.

©2010 Wolfram Research, Inc. except for portions noted otherwise

Code

TicTacToeBoard[]:=Module[{l={{{1,0},{1,3}},{{2,0},{2,3}}}},
{Thickness[.02],Line/@l,Line/@Map[Reverse,l,{2}]}
]

TTT[{x_,y_},1]:=Module[{r=.35,x0=1.5,y0=1.5},
{
Line[{x0,y0}+#&/@{{x-r,y+r},{x+r,y-r}}],
Line[{x0,y0}+#&/@{{x+r,y+r},{x-r,y-r}}]
}
]

TTT[{x_,y_},0]:=Module[{r=.35,x0=1.5,y0=1.5},
Circle[{x0+x,y0+y},r]
]

TTT[{x_,y_},Null]:={}

Configuration[m_]:=Table[TTT[{2-j,2-i},m[[i,4-j]]],{i,3},{j,3}]

TicTacToeBoard[m_List?MatrixQ]:={TicTacToeBoard[],Configuration[m]}

V5

Show[GraphicsArray[{
Graphics[{Thickness[.02],TicTacToeBoard[]
},AspectRatio->Automatic],
Graphics[{
Thickness[.02],
TicTacToeBoard[{{1,,0},{,1,0},{,0,1}}],
{Thickness[.01],Red,Line[{{0,3},{3,0}}]}
},AspectRatio->Automatic]
}]]

V6

GraphicsRow[{
Graphics[{Thickness[.02],TicTacToeBoard[]}],
Graphics[{
Thickness[.02],
TicTacToeBoard[{{1,,0},{,1,0},{,0,1}}],
{Thickness[.01],Red,Line[{{0,3},{3,0}}]}
}]
}]