Message Boards Message Boards

GROUPS:

Cellular Automata with 2D matrix initialization

Posted 4 years ago
5299 Views
|
2 Replies
|
5 Total Likes
|

Here's a rather fun snippet of code from my increasingly large notebook of interesting CA programs:

init=
{{1,1,1,1,1,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1},
{0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0},
{0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0},
{0,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1},
{0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0},
{0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0},
{0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0},
{1,1,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1}};

tostep[r_,s_,init_]:=Table[CellularAutomaton[r,i,{{s}}][[1]],{i,init}]
<!-- this is to separate the two code blocks. it's a useful trick! -->
ArrayPlot[init]

the word JESSE in an ArrayPlot

ArrayPlot[tostep[30, 20,init]]

a seemingly random ArrayPlot of the same dimensions as the first, but processed with the tostep function

Manipulate[
 ArrayPlot[tostep[r, s,init]], {{r, 30}, 1, 255, 1}, {{s, 20}, 0, 200, 1}]

a Manipulate of the CA rule and step set at 83 and 20 respectively. The output bears some resemblance to the input JESSE matrix.

It's interesting to see what rule and step combinations result in a resemblance to the original matrix.

2 Replies
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract