generates a list representing the evolution of the cellular automaton with the specified rule from initial condition init for t steps.


gives the result of evolving init for one step.


gives only those parts of the evolution specified by tspec, xspec, etc.


includes at each step all cells that could be affected over the course of t steps.


is an operator form of CellularAutomaton that represents one step of evolution.


  • Possible forms for rule are:
  • n, , elementary rule with rule number n
    {n,k}general nearestneighbor rule with k colors
    {n,k,r}general rule with k colors and range r
    {n,k,{r1,r2,,rd}}ddimensional rule with neighborhood
    {n,k,{{off1},{off2},,{offs}}} rule with neighbors at specified offsets
    {n,k,rspec,s}orders rule
    {n,{k,1}}kcolor nearestneighbor totalistic rule
    {n,{k,1},r}kcolor range-r totalistic rule
    {n,{k,{wt1,wt2,}},rspec}rule in which neighbor i is assigned weight wti
    {lhs1->rhs1,lhs2->rhs2,}explicit replacements for lists of neighbors
    {fun,{},rspec}general function fun to apply to each list of neighbors
    bfunBoolean function to apply to collections of neighbors
    CellularAutomaton[rule]operator form of a rule
    <|"key1"val1,"key2"val2,|>rule specification by an association
    "name"named rule
  • CellularAutomaton[{n,k},] is equivalent to CellularAutomaton[{n,{k,{k^2,k,1}}},].
  • The following keys can be used to specify a rule given as an association:
  • "RuleNumber"nrule number
    "TotalisticCode"ntotalistic code
    "OuterTotalisticCode"nouter totalistic code
    "GrowthCases"{g1,g2,}make a cell 1 when gi of its neighbors are 1
    "GrowthSurvivalCases"{{g1,},{s1,}}1 for gi neighbors; unchanged for si
    "GrowthDecayCases"{{g1,},{d1,}}1 for gi neighbors; 0 for di
    "Dimension"doverall dimension
    "Colors"knumber of colors
    "Range"rrange of rule
    "Neighborhood"typeneighborhood type
  • With "GrowthCases"->{g1,g2,}, a cell goes from value 0 to value 1 if it has gi neighbors that are 1; otherwise it stays the same as before.
  • With "GrowthSurvivalCases"->{{g1,},{s1,}}, a cell goes from value 0 to value 1 if it has gi neighbors that are 1, maintains value 1 if it has si neighbors that are 1, and otherwise gets value 0.
  • With "GrowthDecayCases"->{{g1,},{d1,}}, a cell goes from value 0 to value 1 if it has gi neighbors that are 1, gets value 0 if it has di neighbors that are 1, and otherwise stays the same.
  • Possible settings for "Neighborhood" in 2D include:
  • 5 or "VonNeumann"CrossMatrix[1]
    9 or "Moore"BoxMatrix[1]
  • For dimension d, "Neighborhood" supports "VonNeumann" and "Moore", as well as the integers and .
  • Possible named cellular automaton rules given as CellularAutomaton["name",] include:
  • "Rule30"30
  • Common explicit forms for 2D cellular automaton rules include:
  • {n,{k,1},{1,1}}9neighbor totalistic rule
    5neighbor totalistic rule
    5neighbor outer totalistic rule
  • The number of possible cellular automaton rules is as follows:
  • elementary rules256
    1D general rules
    1D totalistic rules
    2D general rules
    2D 9neighbor totalistic rules
    2D 5neighbor totalistic rules
    2D 5neighbor outer totalistic rules
  • Normally, all elements in init and the evolution list are integers between 0 and .
  • When a general function or a replacement list is used, the elements of init and the evolution list can be any expressions. »
  • Explicit replacement rules lhsi->rhsi can contain patterns.
  • In a 1D cellular automaton, replacement rules or an explicit function fun are always taken to apply to a 1D list of neighbors. If the neighbors are specified by explicit offsets, they are given in the order of the offsets.
  • When the neighborhood in a multidimensional cellular automaton is defined by a range specification such as {r1,r2,}, the list of neighbors is taken to be a full array with dimensions 2{r1,r2,}+1.
  • If the neighbors in a multidimensional cellular automaton are specified by an explicit list of offsets, the neighbors are supplied in a one-dimensional list in the order of the offsets.
  • If an explicit function fun is given, the first argument supplied to it is the list of neighbors. The second argument is the step number starting at 0.
  • A complete rule specification is considered to be a pure Boolean function bfun if BooleanVariables[bfun] yields an integer v. In this case, bfun is applied to neighborhoods of v cells at each step. The neighborhoods extend Ceiling[v/2] cells to the left.
  • In an orders cellular automaton, specified by {rule,kspec,rspec,s}, each step depends on s preceding steps.
  • Initial conditions are constructed from init as follows:
  • {a1,a2,}explicit list of values ai, assumed cyclic
    {{a1,a2,},b}values ai superimposed on a b background
    {{a1,a2,},{b1,b2,}}values ai superimposed on a background of repetitions of b1, b2,
    {{{{a11,a12,},off1}, {{a21,},off2},},bspec}
    values aij at offsets offi on a background
    {{a11,a12,},{a21,},}explicit list of values in two dimensions
    {aspec,bspec}values in d dimensions with ddimensional padding
  • The first element of aspec is superimposed on the background at the first position in the positive direction in each coordinate relative to the origin. This means that bspec[[1,1,]] is aligned with aspec[[1,1,]].
  • CellularAutomaton[rule,init,t] generates an evolution list of length .
  • For an orders cellular automaton, init is a list giving the initial s steps in the evolution of the system.
  • Time specifications tspec in {tspec,xspec,} can be as follows:
  • tall steps 0 through t
    {t}a list containing only step t
    {{t}}step t alone
    {t1,t2}steps t1 through t2
    {t1,t2,dt}steps t1, t1+dt,
  • The initial condition is considered to be at step 0.
  • CellularAutomaton[rule,init,{tspec}] uses the default Automatic for xspec.
  • Space specifications xspec can be as follows:
  • Allall cells that can be affected by the specified initial condition
    Automaticall cells in the region that differs from the background
    0cell aligned with beginning of aspec
    xcells at offsets up to x on the right
    -xcells at offsets up to x on the left
    {x}cell at offset x to the right
    {-x}cell at offset x to the left
    {x1,x2}cells at offsets x1 through x2
    {x1,x2,dx}cells x1, x1+dx,
  • In one dimension, the first element of aspec is taken by default to have space offset 0.
  • In any number of dimensions, aspec[[1,1,1,]] is taken by default to have space offset {0,0,0,}.
  • Each element of the evolution list produced by CellularAutomaton is always the same size.
  • With an initial condition specified by an aspec of width , the region that can be affected after steps by a cellular automaton with a rule of range has width .
  • If no bspec background is specified, space offsets of All and Automatic will include every cell in aspec.
  • A space offset of All includes all cells that can be affected by the initial condition.
  • A space offset of Automatic can be used to trim off background from the sides of a cellular automaton pattern.
  • In working out how wide a region to keep, Automatic only looks at results on steps specified by offt.
  • CellularAutomaton[rule][init] is equivalent to CellularAutomaton[rule,init].


open all close all

Basic Examples  (3)

Run rule 30 for 2 steps:

Click for copyable input

Run for 50 steps from a single 1 on a background of 0s:

Click for copyable input

Generate an icon for a cellular automaton rule:

Click for copyable input

Scope  (91)

Applications  (23)

Properties & Relations  (9)

Possible Issues  (7)

Introduced in 2002
Updated in 2017