login
A271693
Number of active (ON, black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 398", based on the 5-celled von Neumann neighborhood.
4
1, 5, 8, 21, 20, 28, 36, 76, 76, 64, 88, 116, 128, 152, 156, 296, 308, 196, 276, 276, 300, 376, 324, 452, 472, 412, 528, 608, 616, 740, 780, 1004, 1072, 840, 1004, 864, 952, 1072, 952, 1128, 1184, 1196, 1324, 1424, 1268, 1508, 1568, 1920, 1984, 1696, 2168
OFFSET
0,2
COMMENTS
Initialized with a single black (ON) cell at stage zero.
REFERENCES
S. Wolfram, A New Kind of Science, Wolfram Media, 2002; p. 170.
MATHEMATICA
CAStep[rule_, a_]:=Map[rule[[10-#]]&, ListConvolve[{{0, 2, 0}, {2, 1, 2}, {0, 2, 0}}, a, 2], {2}];
code=398; stages=128;
rule=IntegerDigits[code, 2, 10];
g=2*stages+1; (* Maximum size of grid *)
a=PadLeft[{{1}}, {g, g}, 0, Floor[{g, g}/2]]; (* Initial ON cell on grid *)
ca=a;
ca=Table[ca=CAStep[rule, ca], {n, 1, stages+1}];
PrependTo[ca, a];
(* Trim full grid to reflect growth by one cell at each stage *)
k=(Length[ca[[1]]]+1)/2;
ca=Table[Table[Part[ca[[n]][[j]], Range[k+1-n, k-1+n]], {j, k+1-n, k-1+n}], {n, 1, k}];
Map[Function[Apply[Plus, Flatten[#1]]], ca] (* Count ON cells at each stage *)
CROSSREFS
Sequence in context: A198635 A178675 A271087 * A271281 A246330 A034737
KEYWORD
nonn,easy
AUTHOR
Robert Price, Apr 12 2016
STATUS
approved