ca {cellularautomata}R Documentation

Create Cellular Automaton

Description

Create Cellular Automaton

Usage

ca(wolframrule, initialstate, steps = 100, ncols = 101, wrap = TRUE)

Arguments

wolframrule

integer identifying the algorithm according to Wolfram numbering

initialstate

a vector setting up the initial state

steps

integer spacifying for how long to run the algorithm

ncols

how many columns to have. If 'initialstate' is specified, 'ncols' is calculated as 'length(initialstate)'. If 'initialstate' is not specified, it is defined as a 1 in the middle of zeros. For instance, with the default 'ncols = 11', the 'initialstate' is a vector of 5 zeros, 1, and another 5 zeros.

wrap

boolean, default is TRUE. Whether it uses a circular wrap at the end and beginning of lines. If FALSE it puts empty slots on the first and last columns.

Value

an object of class 'c("cellular_automaton", "matrix")'

Author(s)

Adapted from code by Nicola Procopio

References

<https://en.wikipedia.org/wiki/Cellular_automaton>

Examples

# Wolfram's rule 30
ca(30)

# Wolfram's rule 126 with a random initial state
ca(126,
   initialstate = sample(c(0, 1), size = 100, replace = TRUE),
   steps = 100)


[Package cellularautomata version 0.1.0 Index]