README
CellularAutomata
Raku package for representation and evolution of cellular automata.
Installation
From Zef ecosystem:
zef install CellularAutomataFrom GitHub:
zef install https://github.com/antononcube/Raku-CellularAutomata.gitUsage examples
Two steps of Rule 30 over a specified array:
use CellularAutomata;
cellular-automaton(30, [1, 0, 0, 0, 0, 0], 2)# [[1 0 0 0 0 0] [1 1 0 0 0 1] [0 0 1 0 1 1]]Four steps of initialization specification:
.say for cellular-automaton(30, [[1,], 0], 4)# [0 0 0 0 1 0 0 0 0]
# [0 0 0 1 1 1 0 0 0]
# [0 0 1 1 0 0 1 0 0]
# [0 1 1 0 1 1 1 1 0]
# [1 1 0 0 1 0 0 0 1]Show the table of rule 90;
rule-table(90, method => Whatever); # method takes also 'text' and 'html' # ā ā ā ā ā ā” ā ā”ā ā ā”ā” ā”ā ā ā”ā ā” ā”ā”ā ā”ā”ā”
# ā” ā ā” ā ā ā” ā ā”Show rules of rule 90:
use CellularAutomata::Utilities;
cellular-automaton-from-number(90)# ((1 1 1) => 0 (1 1 0) => 1 (1 0 1) => 0 (1 0 0) => 1 (0 1 1) => 1 (0 1 0) => 0 (0 0 1) => 1 (0 0 0) => 0)Plot the array of 20 steps of Rule 30:
use Graphviz::DOT::Chessboard;
my @mat = cellular-automaton(30,[[1,], 0], 20);
dot-matrix-plot(@mat, :9graph-size, :0tick-font-size, :0tick-offset):svgFor more examples see the Jupyter notebook "CellularAutomaton.ipynb".
References
[Wk1] Wikipedia entry, "Cellular automaton".
[WRI1] Wolfram Research, Inc., CellularAutomaton, (2002 introduced, 2017 last update), Wolfram Language & System Documentation Center