Creating Raster Image Animation
- To: mathgroup at smc.vnet.net
- Subject: [mg21854] Creating Raster Image Animation
- From: Mike Fuller <mmfuller at unm.edu>
- Date: Wed, 2 Feb 2000 22:54:13 -0500 (EST)
- Organization: University of New Mexico, Albuquerque
- Sender: owner-wri-mathgroup at wolfram.com
I'm trying to get a graphical representation of a cellular automata to work. I've implemented Conway's Game of Life using code provided by Gaylord et al. The code creates a matrix showing the location of "living" and "dead" cells. This program works fine. But I'm having trouble getting an animated representation to work. When I try to evaluate the output from the Game, using a separate program, it simply produces the same output as the Game (a matrix of values). Does anyone have any idea how I can modify the code to my ShowLife program (below) get the desired result? Thanks, Mike Here's the code for the CA: LifeGame[s_, t_]:= Module[{initconfig, livingNghbrs, update}, initconfig = Table[Random[Integer], {s}, {s}]; livingNghbrs[mat_] := Apply[Plus, Map[RotateRight[mat, #]&, {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1}, {1,0},{1,1}}]]; update[1,2]:= 1; update[_,3]:= 1; update[_,_]:= 0; Attributes[update]=Listable; FixedPointList[update[#, livingNghbrs[#]]&, initconfig, t]] And here's the code for the graphic animation: ShowLife[list_, opts__Rule]:= Map[(Show[Graphics[RasterArray[ Reverse[list[[#]]/. {1-> RGBColor[1,0,0], 0-> RGBColor[0,0,0]}]], AspectRatio-> Automatic, opts]])&, Range[Length[list]]]