Conway's Soldiers

Author

Eric W. Weisstein
January 5, 2007

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Games/ConwaysSoldiers.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/ConwaysSoldiers.html.

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

Code

grid[{x_,y_,off_},y0_,ex_,pts_]:=Module[{h=.5,e=.2,dx=.3,i,j,t=.008},{
Table[Line[(off+{h,h}+#)&/@{{-e,j},{x+e,j}}],{j,0,y}],
Table[Line[(off+{h,h}+#)&/@{{i,-e},{i,y+e}}],{i,0,x}],
{Red,Thickness[t],Line[(off+{h,h}+#)&/@{{-e,y0},{x+e,y0}}]},
{Thickness[t],
Line[(off+#)&/@{ex-dx,ex+dx}],
Line[{off+ex+dx{-1,1},off+ex+dx{1,-1}}]
},
{Blue,Disk[off+#,.4]&/@pts},
Circle[off+#,.4]&/@pts
}
]

conway={
grid[{3,5,{0,0}},3,{2,4},{{2,2},{2,3}}],
grid[{4,5,{4,0}},3,{3,5},{{1,3},{2,3},{3,3},{3,2}}],
grid[{5,8,{9,-1}},4,{3,7},
Join[{#,4}&/@Range[5],{3,#}&/@Range[3]]
],
grid[{7,8,{15,-1}},4,{5,8},
Join[
{#,4}&/@Range[7],
{#,3}&/@Range[3,7],
{#,2}&/@Range[2,7],
{#,1}&/@Range[4,5]
]
]
};

Figure

Show[Graphics[conway,AspectRatio->Automatic,PlotRange->All]]