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

FUNCTIONS

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

OEIS

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

SEE ALSO

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

HOME PAGE

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

LICENSE

155       Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 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.28.1                      2017-12-03  Math::PlanePath::CellularRule(3)
Impressum