DOKK / manpages / debian 10 / libmath-planepath-perl / Math::PlanePath::CellularRule57.3pm.en
Math::PlanePath::CellularRule57(3pm) User Contributed Perl Documentation Math::PlanePath::CellularRule57(3pm)

Math::PlanePath::CellularRule57 -- cellular automaton 57 and 99 points

 use Math::PlanePath::CellularRule57;
 my $path = Math::PlanePath::CellularRule57->new;
 my ($x, $y) = $path->n_to_xy (123);

This is the pattern of Stephen Wolfram's "rule 57" cellular automaton

<http://mathworld.wolfram.com/ElementaryCellularAutomaton.html>

arranged as rows

                51       52       53 54    55 56                 10
    38 39 40 41       42       43    44 45    46 47 48 49 50      9
                   33       34    35    36 37                     8
          23 24 25       26       27 28    29 30 31 32            7
                      19       20    21 22                        6
                12 13       14    15    16 17 18                  5
                          9       10 11                           4
                       5        6     7  8                        3
                             3     4                              2
                                   2                              1
                                1                             <- Y=0
    -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7  8  9

The triangular numbers N=10,15,21,28,etc, k*(k+1)/2, make a 1/2 sloping diagonal upwards.

On rows with odd Y there's a solid block at either end then 1 of 3 cells to the left and 2 of 3 to the right of the centre. On even Y rows there's similar 1 of 3 and 2 of 3 middle parts, but without the solid ends. Those 1 of 3 and 2 of 3 are successively offset so as to make lines going up towards the centre as can be seen in the following plot.

    ***********  *  *  *  * * ** ** ** ************
                *  *  *  *  ** ** ** **
      **********  *  *  *  * ** ** ** ***********
                 *  *  *  * * ** ** **
        *********  *  *  *  ** ** ** **********
                  *  *  *  * ** ** **
          ********  *  *  * * ** ** *********
                   *  *  *  ** ** **
            *******  *  *  * ** ** ********
                    *  *  * * ** **
              ******  *  *  ** ** *******
                     *  *  * ** **
                *****  *  * * ** ******
                      *  *  ** **
                  ****  *  * ** *****
                       *  * * **
                    ***  *  ** ****
                        *  * **
                      **  * * ***
                         *  **
                        *  * **
                          * *
                            *
                           *

The "mirror => 1" option gives the mirror image pattern which is "rule 99". The point numbering shifts but the total points on each row is the same.

                51 52    53 54       55       56                  10
    38 39 40 41 42    43 44    45       46       47 48 49 50       9 
                   33 34    35    36       37                      8 
          23 24 25 26    27 28       29       30 31 32             7 
                      19 20    21       22                         6 
                12 13 14    15    16       17 18                   5 
                          9 10       11                            4 
                       5  6     7        8                         3 
                             3     4                               2 
                             2                                     1 
                                1                              <- Y=0
    -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7  8  9

The default is to number points starting N=1 as shown above. An optional "n_start" can give a different start, in the same pattern. For example to start at 0,

    n_start => 0
    22 23 24       25       26 27    28 29 30 31
                18       19    20 21            
          11 12       13    14    15 16 17      
                    8        9 10               
                 4        5     6  7            
                       2     3                  
                             1                  
                          0

See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.

"$path = Math::PlanePath::CellularRule57->new ()"
"$path = Math::PlanePath::CellularRule57->new (mirror => $bool, n_start => $n)"
Create and return a new path object.
"($x,$y) = $path->n_to_xy ($n)"
Return the X,Y coordinates of point number $n on the path.
"$n = $path->xy_to_n ($x,$y)"
Return the point number for coordinates "$x,$y". $x and $y are each rounded to the nearest integer, which has the effect of treating each cell as a square of side 1. If "$x,$y" is outside the pyramid or on a skipped cell the return is "undef".

Math::PlanePath, Math::PlanePath::CellularRule, Math::PlanePath::CellularRule54, Math::PlanePath::CellularRule190, Math::PlanePath::PyramidRows

<http://mathworld.wolfram.com/ElementaryCellularAutomaton.html>

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

Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde

This file is part of Math-PlanePath.

Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-PlanePath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.

2018-03-18 perl v5.26.1