Cellular Automata

Create cellular automata from 'Wolfram' rules. Allows the creation of 'Wolfram' style plots, as well as of animations. Easy to create multiple plots, for example the output of a rule with different initial states, or the output of many different rules from the same state. The output of a cellular automaton is given as a matrix, making it easy to try to explore the possibility of predicting its time evolution using various statistical tools available in R. Wolfram S. (2002, ISBN:1579550088) "A New Kind of Science".


An R package for creating cellular automata.

library(cellularautomata)

Create the plot of a cellular automaton

You can generate a cellular automaton using the ca function, specifying the Wolfram rule. For example:

ca(18) |> plot()
ca(30) |> plot()
ca(45) |> plot()
ca(195) |> plot()

Rule 18

Rule 30

Rule 45

Rule 195

Animations

You can get an animation of a cellular automaton using plot(animate = TRUE):

ca(30, ncols = 20, steps = 30) |> plot(animate = TRUE)

Rule 30

Polar coordinates

By default the line is wrapped, meaning it is actually a circle, with the end connected to the beginning.

You can plot it using polar coordinates:

ca(193, steps = 50) |> plot(time_flow = "up", circle = TRUE)

Rule 193, polar coordinates

This also works for animations:

ca(193, ncols = 25, steps = 100) |> plot(circle = TRUE, animate = TRUE)

Rule 193, polar coordinates

Acknowledgements

Original function created by Nicola Procopio.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("cellularautomata")

0.1.0 by Vlad Tarko, 2 years ago


Browse source code at https://github.com/cran/cellularautomata


Authors: Vlad Tarko [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports gganimate, ggplot2, patchwork, purrr, rlang

Suggests knitr, rmarkdown


See at CRAN