Life

Author

Eric W. Weisstein
April 15, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/CellularAutomata/Life.nb.

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

For a list of Eric's math packages that may be needed to evaluate this notebook, see http://mathworld.wolfram.com/packages/.  An archive of these packages may be downloaded from http://mathworld.wolfram.com/packages/MathWorldPackages.zip, as well as from the Mathematica Information Center's MathSource item 4775.  A list of Eric's utility packages that may be needed to evaluate this notebook may be downloaded from MathSource item 5087.

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

Initialization

<<MathWorld`Life`

Still Lifes

stilllifes={
{"block","tub"},
{"boat"},
{"snake","ship","aircraft carrier","beehive","barge"},
{"Python","long boat","eater, fishhook","loaf"}
};

Show[LifeArray[stilllifes]]

Puffer Train

Show[CellGraphics[Configuration["puffer train"]]]

Show/@(movie=CellGraphics[#]&/@Life[Transpose[Configuration["puffer train"]],50])

Garden of Eden

gardens={"Garden of Eden (Flammenkamp)","Garden of Eden"};

Show[GraphicsArray[List/@(CellGraphics[Configuration[#]]&/@gardens),GraphicsSpacing->-.3]]

Oscillators

<<LinearAlgebra`MatrixManipulation`

LifeBlock[l_List]:=Module[{d=Map[Max,Transpose/@Map[Dimensions[Configuration[#]]&,l,{2}],{2}],rows,w},
rows=AppendRows@@@Map[PadRight[PadLeft[Configuration[#[[1]]],{1,1}+#[[2]]],#[[2]]+{2,2}]&,
MapIndexed[{#1,d[[#2[[1]]]]}&,l,{2}],{2}];
w=Transpose[Dimensions/@rows];
AppendColumns@@
Table[PadRight[rows[[i]],{w[[1,i]],Max[w[[-1]]]}],{i,Length[rows]}]
]

oscillators={
{"blinker"},
{"toad","beacon","clock"},
{"bipole"},
{"phoenix"}
};

Show[PaddedArray[oscillators]]

Show/@CellGraphics/@Life[LifeBlock[oscillators],10]

GIFs

<<GIF`

Export[gifs<>"puffertr.gif",movie]//Timing

Import Life patterns into a Mathematica-readable format

AppendTo[$Path,"/Volumes/Data/Mathematica/Packages/Life"];

SetOptions[CellMatrix,LifeDir->"/Volumes/Data/Mathematica/Packages/Life/"]

l=ReadList["/Volumes/Data/Mathematica/Packages/Life/LifeNames.lif",String]

Length[l]

out=OpenWrite["/Volumes/Data/Mathematica/Packages/Life/Lifes.m"]

Timing[good=Flatten[Position[c=Check[CellMatrix[#],{}]&/@l,_?(#=!={}&),{1},Heads->False]];]

Length[good]

WriteString[out,Sequence@@("Configuration[\""<>l[[#]]<>"\"]:="<>StringReplace[ToString[c[[#]]]," "->""]<>"\n"&/@good)
]

Close[out]