1Math::PlanePath::CellulUasreRrulCeo1n9t0r(i3b)uted PerlMDaotchu:m:ePnltaanteiPoanth::CellularRule190(3)
2
3
4
6 Math::PlanePath::CellularRule190 -- cellular automaton 190 and 246
7 points
8
10 use Math::PlanePath::CellularRule190;
11 my $path = Math::PlanePath::CellularRule190->new;
12 my ($x, $y) = $path->n_to_xy (123);
13
15 This is the pattern of Stephen Wolfram's "rule 190" cellular automaton
16
17 <http://mathworld.wolfram.com/Rule190.html>
18
19 arranged as rows,
20
21 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 9
22 53 54 55 56 57 58 59 60 61 62 63 64 65 8
23 41 42 43 44 45 46 47 48 49 50 51 52 7
24 31 32 33 34 35 36 37 38 39 40 6
25 22 23 24 25 26 27 28 29 30 5
26 15 16 17 18 19 20 21 4
27 9 10 11 12 13 14 3
28 5 6 7 8 2
29 2 3 4 1
30 1 <- Y=0
31
32 -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6 7 8 9
33
34 Each row is 3 out of 4 cells. Even numbered rows have one point on its
35 own at the end. Each two-row group has a step of 6 more points than
36 the previous two-row.
37
38 The of rightmost N=1,4,8,14,21,etc are triangular plus quarter square,
39 ie.
40
41 Nright = triangular(Y+1) + quartersquare(Y+1)
42 triangular(t) = t*(t+1)/2
43 quartersquare(t) = floor(t^2/4)
44
45 The rightmost N=1,8,21,40,65,etc on even rows Y=0,2,4,6,etc are the
46 octagonal numbers k*(3k-2). The octagonal numbers of the "second kind"
47 N=5,16,33,56,85, etc, k*(3k+2) are a straight-ish line upwards to the
48 left.
49
50 Mirror
51 The "mirror => 1" option gives the mirror image pattern which is "rule
52 246". It differs only in the placement of the gaps on the even rows.
53 The point on its own is at the left instead of the right. The
54 numbering is still left to right.
55
56 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 9
57 53 54 55 56 57 58 59 60 61 62 63 64 65 8
58 41 42 43 44 45 46 47 48 49 50 51 52 7
59 31 32 33 34 35 36 37 38 39 40 6
60 22 23 24 25 26 27 28 29 30 5
61 15 16 17 18 19 20 21 4
62 9 10 11 12 13 14 3
63 5 6 7 8 2
64 2 3 4 1
65 1 <- Y=0
66
67 -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6 7 8 9
68
69 Sometimes this small change to the pattern helps things line up better.
70 For example plotting the Klaner-Rado sequence gives some unplotted
71 lines up towards the right in the mirror 246 which are not visible in
72 the plain 190.
73
74 Row Ranges
75 The left end of each row, both ordinary and mirrored, is
76
77 Nleft = ((3Y+2)*Y + 4)/4 if Y even
78 ((3Y+2)*Y + 3)/4 if Y odd
79
80 The right end is
81
82 Nright = ((3Y+8)*Y + 4)/4 if Y even
83 ((3Y+8)*Y + 5)/4 if Y odd
84
85 = Nleft(Y+1) - 1 ie. 1 before next Nleft
86
87 The row width Xmax-Xmin = 2*Y but with the gaps the number of visited
88 points in a row is less than that,
89
90 rowpoints = 3*Y/2 + 1 if Y even
91 3*(Y+1)/2 if Y odd
92
93 For any Y of course the Nleft to Nright difference is the number of
94 points in the row too
95
96 rowpoints = Nright - Nleft + 1
97
98 N Start
99 The default is to number points starting N=1 as shown above. An
100 optional "n_start" can give a different start, in the same pattern.
101 For example to start at 0,
102
103 n_start => 0
104
105 21 22 23 24 25 26 27 28 29 5
106 14 15 16 17 18 19 20 4
107 8 9 10 11 12 13 3
108 4 5 6 7 2
109 1 2 3 1
110 0 <- Y=0
111
112 -5 -4 -3 -2 -1 X=0 1 2 3 4 5
113
114 The effect is to push each N rightwards by 1, and wrapping around. So
115 the N=0,1,4,8,14,etc on the left were on the right of the default
116 n_start=1. This also has the effect of removing the +1 in the Nright
117 formula given above, so
118
119 Nleft = triangular(Y) + quartersquare(Y)
120
122 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
123 classes.
124
125 "$path = Math::PlanePath::CellularRule190->new ()"
126 "$path = Math::PlanePath::CellularRule190->new (mirror => 1, n_start =>
127 $n)"
128 Create and return a new path object.
129
130 "($x,$y) = $path->n_to_xy ($n)"
131 Return the X,Y coordinates of point number $n on the path.
132
133 "$n = $path->xy_to_n ($x,$y)"
134 Return the point number for coordinates "$x,$y". $x and $y are
135 each rounded to the nearest integer, which has the effect of
136 treating each cell as a square of side 1. If "$x,$y" is outside
137 the pyramid or on a skipped cell the return is "undef".
138
139 "($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)"
140 The returned range is exact, meaning $n_lo and $n_hi are the
141 smallest and biggest in the rectangle.
142
144 This pattern is in Sloane's Online Encyclopedia of Integer Sequences in
145 a couple of forms,
146
147 <http://oeis.org/A037576> (etc)
148
149 A037576 whole-row used cells as bits of a bignum
150 A265688 and in binary
151 A071039 1/0 used and unused cells across rows
152 A118111 same
153 A071041 1/0 used and unused of mirrored rule 246
154
155 n_start=0
156 A006578 N at left of each row (X=-Y),
157 and at right of each row when mirrored,
158 being triangular+quartersquare
159
161 Math::PlanePath, Math::PlanePath::CellularRule,
162 Math::PlanePath::CellularRule54, Math::PlanePath::CellularRule57,
163 Math::PlanePath::PyramidRows
164
165 Cellular::Automata::Wolfram
166
167 <http://mathworld.wolfram.com/Rule190.html>
168
170 <http://user42.tuxfamily.org/math-planepath/index.html>
171
173 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
174 Kevin Ryde
175
176 This file is part of Math-PlanePath.
177
178 Math-PlanePath is free software; you can redistribute it and/or modify
179 it under the terms of the GNU General Public License as published by
180 the Free Software Foundation; either version 3, or (at your option) any
181 later version.
182
183 Math-PlanePath is distributed in the hope that it will be useful, but
184 WITHOUT ANY WARRANTY; without even the implied warranty of
185 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
186 General Public License for more details.
187
188 You should have received a copy of the GNU General Public License along
189 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
190
191
192
193perl v5.34.0 2022-01-21Math::PlanePath::CellularRule190(3)