Math::...rRule57(3pm)

πŸ“¦
version 129 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Math::PlanePath::CellularRule57 β€” cellular automaton 57 and 99 points

okay so bestie, quick heads up before anything: this page is Math::...rRule57(3pm), from the User Contributed Perl Documentation collection. yes the title got truncated, she's just like that. πŸ’…


✨ SYNOPSIS ✨

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

🌸 DESCRIPTION 🌸

So this is literally Stephen Wolfram's "rule 57" cellular automaton, laid out in rows:

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

               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. iconic behavior honestly.

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 a 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 you can see in the following plot:

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

πŸ¦‹ Mirror

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, no cap.

               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

✨ N Start

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

🫢 FUNCTIONS 🫢

See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes, bestie. that's the shared lore.

  • $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". 😭 yeah she just says undef, no explanation, no apology.

πŸ’œ SEE ALSO πŸ’œ

  • Math::PlanePath
  • Math::PlanePath::CellularRule
  • Math::PlanePath::CellularRule54
  • Math::PlanePath::CellularRule190
  • Math::PlanePath::PyramidRows

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


🌈 HOME PAGE 🌈

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


πŸ‘‘ LICENSE πŸ‘‘

Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 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/>.


and that's the whole page bestie!! πŸ’– this one came from perl v5.32.0, dated 2021-01-23, filed under User Contributed Perl Documentation β€” go forth and plot ur little triangles, no cap πŸ¦‹βœ¨