1Math::PlanePath::CellulUasreRrulCeo(n3t)ributed Perl DocMuamtehn:t:aPtliaonnePath::CellularRule(3)
2
3
4

NAME

6       Math::PlanePath::CellularRule -- cellular automaton points of binary
7       rule
8

SYNOPSIS

10        use Math::PlanePath::CellularRule;
11        my $path = Math::PlanePath::CellularRule->new (rule => 30);
12        my ($x, $y) = $path->n_to_xy (123);
13

DESCRIPTION

15       This is the patterns of Stephen Wolfram's bit-rule cellular automatons
16
17           <http://mathworld.wolfram.com/ElementaryCellularAutomaton.html>
18
19       Points are numbered left to right in rows so for example
20
21           rule => 30
22
23           51 52    53 54 55 56    57 58       59          60 61 62       9
24              44 45       46          47 48 49                50          8
25                 32 33    34 35 36 37       38 39 40 41 42 43             7
26                    27 28       29             30       31                6
27                       18 19    20 21 22 23    24 25 26                   5
28                          14 15       16          17                      4
29                              8  9    10 11 12 13                         3
30                                 5  6        7                            2
31                                    2  3  4                               1
32                                       1                              <- Y=0
33
34           -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7  8  9
35
36       The automaton starts from a single point N=1 at the origin and grows
37       into the rows above.  The "rule" parameter controls how the 3 cells
38       below and diagonally below produce a new cell,
39
40                    +-----+
41                    | new |              next row, Y+1
42                    +-----+
43                   ^   ^   ^
44                 /     |     \
45                /      |      \
46           +-----+  +-----+  +-----+
47           |  A  |  |  B  |  |  C  |     row Y
48           +-----+  +-----+  +-----+
49
50       There's 8 combinations of ABC being each 0 or 1.  Each such combination
51       can become 0 or 1 in the "new" cell.  Those 0 or 1 for "new" is encoded
52       as 8 bits to make a rule number 0 to 255,
53
54           ABC cells below     new cell bit from rule
55
56                  1,1,1   ->   bit7
57                  1,1,0   ->   bit6
58                  1,0,1   ->   bit5
59                  ...
60                  0,0,1   ->   bit1
61                  0,0,0   ->   bit0
62
63       When cells 0,0,0 become 1, ie. "rule" bit0 is 1 (an odd number), the
64       "off" cells either side of the initial N=1 become all "on" infinitely
65       to the sides.  Or if rule bit7 for 1,1,1 is a 0 (ie. rule < 128) then
66       they turn on and off alternately in odd and even rows.  In both cases
67       only the pyramid portion part -Y<=X<=Y is considered for the N points
68       but the infinite cells to the sides are included in the calculation.
69
70       The full set of patterns can be seen at the MathWorld page above, or
71       can be printed with the examples/cellular-rules.pl here.  The patterns
72       range from simple to complex.  For some, the N=1 cell doesn't grow at
73       all such as rule 0 or rule 8.  Some grow to mere straight lines such as
74       rule 2 or rule 5.  Others make columns or patterns with "quadratic"
75       style stepping of 1 or 2 rows, or self-similar replications such as the
76       Sierpinski triangle of rule 18 and 60.  Some rules have complicated
77       non-repeating patterns when there's feedback across from one half to
78       the other, such as rule 30.
79
80       For some rules there's specific PlanePath code which this class
81       dispatches to, such as "CellularRule54", "CellularRule57",
82       "CellularRule190" or "SierpinskiTriangle" (with "n_start=1").
83
84       For rules without specific code, the current implementation is not
85       particularly efficient as it builds and holds onto the bit pattern for
86       all rows through to the highest N or X,Y used.  There's no doubt better
87       ways to iterate an automaton, but this module offers the patterns in
88       PlanePath style.
89
90   N Start
91       The default is to number points starting N=1 as shown above.  An
92       optional "n_start" can give a different start, in the same pattern.
93       For example to start at 0,
94
95           n_start => 0, rule => 62
96
97           18 19    20 21    22    23 24 25          5
98              13 14    15 16          17             4
99                  7  8     9 10 11 12                3
100                     4  5        6                   2
101                        1  2  3                      1
102                           0                     <- Y=0
103
104           -5 -4 -3 -2 -1 X=0 1  2  3  4  5
105

FUNCTIONS

107       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
108       classes.
109
110       "$path = Math::PlanePath::CellularRule->new (rule => 123)"
111       "$path = Math::PlanePath::CellularRule->new (rule => 123, n_start =>
112       $n)"
113           Create and return a new path object.  "rule" should be an integer 0
114           to 255.  A "rule" should be given always.  There is a default, but
115           it's secret and likely to change.
116
117           If there's specific PlanePath code implementing the pattern then
118           the returned object is from that class and generally is not
119           "isa('Math::PlanePath::CellularRule')".
120
121       "$n = $path->xy_to_n ($x,$y)"
122           Return the point number for coordinates "$x,$y".  $x and $y are
123           each rounded to the nearest integer, which has the effect of
124           treating each cell as a square of side 1.  If "$x,$y" is outside
125           the pyramid or on a skipped cell the return is "undef".
126

OEIS

128       Entries in Sloane's Online Encyclopedia of Integer Sequences related to
129       this path can be found in the OEIS index
130
131           <http://oeis.org/wiki/Index_to_OEIS:_Section_Ce#cell>
132
133       and in addition the following
134
135           <http://oeis.org/A061579> (etc)
136
137           rule=50,58,114,122,178,186,242,250, 179
138             (solid every second cell)
139             A061579     permutation N at -X,Y (mirror horizontal)
140

SEE ALSO

142       Math::PlanePath, Math::PlanePath::CellularRule54,
143       Math::PlanePath::CellularRule57, Math::PlanePath::CellularRule190,
144       Math::PlanePath::SierpinskiTriangle, Math::PlanePath::PyramidRows
145
146       Cellular::Automata::Wolfram
147
148       <http://mathworld.wolfram.com/ElementaryCellularAutomaton.html>
149

HOME PAGE

151       <http://user42.tuxfamily.org/math-planepath/index.html>
152

LICENSE

154       Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
155       Kevin Ryde
156
157       This file is part of Math-PlanePath.
158
159       Math-PlanePath is free software; you can redistribute it and/or modify
160       it under the terms of the GNU General Public License as published by
161       the Free Software Foundation; either version 3, or (at your option) any
162       later version.
163
164       Math-PlanePath is distributed in the hope that it will be useful, but
165       WITHOUT ANY WARRANTY; without even the implied warranty of
166       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
167       General Public License for more details.
168
169       You should have received a copy of the GNU General Public License along
170       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
171
172
173
174perl v5.34.0                      2021-07-22  Math::PlanePath::CellularRule(3)
Impressum