Group Abstract Group Abstract

Message Boards Message Boards

Conway's structures

Posted 8 years ago
Attachments:
POSTED BY: Hans Dolhaine
3 Replies

Found a solution. But are there more elegant, meaning less memory-consuming ones?

gg = CellularAutomaton[{224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}}, {gun0, 0}, {80, {1, nx}, {1, ny}}];
ee = CellularAutomaton[{224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}}, {eater0, 0}, {80, {1, nx}, {1, ny}}] /.  1 -> -1;


allplt1 = 
 ListAnimate[
  ArrayPlot[#, ImageSize -> 400, Mesh -> True,  ColorRules -> {1 -> Red, -1 -> Blue}] & /@ (gg + ee)]
POSTED BY: Hans Dolhaine

In the meantime I figured out how to get the results given in the notebook with the Mma-built-in cellular automata (apart from the direction of the graphics). Two problems remain: how to explain the code 224 for Conways Game Of Life, and how could one assign different colors to different objects in the combined graphics. I tried to do it with a ColorFunction depending on x and y, but to no avail.

So for the cellular automata define the gun and the eater as

gundat = {
   7, 2, 8, 2, 7, 3, 8, 3,
   7, 13, 8, 13, 9, 13,
   6, 14, 10, 14,
   5, 15, 11, 15, 6, 16, 10, 16,
   7, 17, 8, 17, 9, 17,
   7, 18, 8, 18, 9, 18,
   5, 23, 6, 23, 7, 23,
   4, 24, 5, 24, 7, 24, 8, 24,
   4, 25, 5, 25, 7, 25, 8, 25, 4, 26, 5, 26, 6, 26, 7, 26, 8, 26,
   3, 27, 4, 27, 8, 27, 9, 27, 7, 32, 8, 32, 5, 36, 6, 36, 5, 37, 6, 
   37};

eaterdat = {
   3, 2, 3, 3, 2, 4, 4, 4, 3, 5, 3, 6, 3, 7, 3, 8, 2, 9, 4, 9, 3, 10, 
   3, 11};

Here are the functions do convert the data to elements of a sparse array ( tx and ty shift the data in x- and y-direction)

gun[tx_, ty_] :=  SparseArray[  Rule[#[[1]], #[[2]]] & /@ ({{tx, ty} + #, 1} & /@ Partition[gundat, 2]), {nx, ny}]
eater[tx_, ty_] :=  SparseArray[  Rule[#[[1]], #[[2]]] & /@ ({{tx, ty} + #, 1} & /@ Partition[eaterdat, 2]), {nx, ny}]

Now define the "playground"

nx = 40; ny = 50;
gun0 = Normal[gun[0, 0]];
eater0 = Normal[eater[25, 35]];

and get the gun (in Red thanks to the ColorRules)

gunplt = ListAnimate[  ArrayPlot[#, ImageSize -> 400, Mesh -> True, ColorRules -> {1 -> Red}] & /@ 
   CellularAutomaton[{224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1,1}}, {gun0, 0}, 80]]

and the eater in black

eaterplt = 
 ListAnimate[ ArrayPlot[#, ImageSize -> 400, Mesh -> True] & /@ 
   CellularAutomaton[{224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1,1}}, {eater0, 0}, 80]]

To put gun and eater in one display just add the matrices (which gives rise to the problems with coloring)

mm = gun0 + eater0; 
allplt =  ListAnimate[
  ArrayPlot[#, ImageSize -> 400, Mesh -> True] & /@ 
   CellularAutomaton[{224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1,1}}, {mm, 0}, 80]]

Question: how to assign different colors to gun and eater?

POSTED BY: Hans Dolhaine

More interesting structures which can be easily coded (note that in the program you give the coordinates of occupied cells as an unstructured list; so if {1,1}, {5,2} and {3,9} are the positions of an object you put in { 1,1,5,2,3,9 } ) are given on these web-sites

https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

https://de.wikipedia.org/wiki/Conways_Spiel_des_Lebens#Conways_Herausforderung

POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard