wolframscience.com

A New Kind of Science: The NKS Forum : Powered by vBulletin version 2.3.0 A New Kind of Science: The NKS Forum > Applied NKS > 3rd Life implementation on page 949
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
Jesse Nochella
WRI

Registered: Mar 2004
Posts: 132

3rd Life implementation on page 949

About Implementing Conway's Life in Mathematica

From page 949a:

Invented by John Conway around 1970 (see page 877), the Life 2D cellular automaton has been much studied in recreational computing, and as described on page 964 many localized structures in it have been identified. Each step in its evolution can be implemented using

LifeStep[a_List] :=
MapThread[If[(#1 == 1 && #2 == 4) || #2 == 3, 1, 0]&,
{a, Sum[RotateLeft[a, {i, j}], {i, -1, 1}, {j, -1, 1}]}, 2]

A more efficient implementation can be obtained by operating not on a complete array of black and white cells but rather just on a list of positions of black cells. With this setup, each step then corresponds to

LifeStep[list_] :=
With[{p=Flatten[Array[List, {3, 3}, -1], 1]}, With[{u = Split[Sort[Flatten[Outer[Plus, list, p, 1], 1]]]},
Union[Cases[u, {x_,_,_}->x],
Intersection[Cases[u, {x_,_,_,_}->x], list]] ]]

(A still more efficient implementation is based on finding runs of length 3 and 4 in Sort[u].)



What is that 3rd and still more efficient implementation?

Report this post to a moderator | IP: Logged

Old Post 02-20-2005 05:56 PM
Jesse Nochella is offline Click Here to See the Profile for Jesse Nochella Click here to Send Jesse Nochella a Private Message Edit/Delete Message Reply w/Quote
Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread


 

wolframscience.com  |  wolfram atlas  |  NKS online  |  Wolfram|Alpha  |  Wolfram Science Summer School  |  web resources  |  contact us

Forum Sponsored by Wolfram Research

© 2004-14 Wolfram Research, Inc. | Powered by vBulletin 2.3.0 © 2000-2002 Jelsoft Enterprises, Ltd. | Disclaimer | Archives