CellularAutomaton
CellularAutomaton[rule,init,t]
generates a list representing the evolution of the cellular automaton with the specified rule from initial condition init for t steps.
CellularAutomaton[rule,init]
gives the result of evolving init for one step.
CellularAutomaton[rule,init,{tspec,xspec,…}]
gives only those parts of the evolution specified by tspec, xspec, etc.
CellularAutomaton[rule,init,{t,All,…}]
includes at each step all cells that could be affected over the course of t steps.
CellularAutomaton[rule]
is an operator form of CellularAutomaton that represents one step of evolution.
Details
 Possible forms for rule are:

n , , elementary rule with rule number n {n,k} general nearest‐neighbor rule with k colors {n,k,r} general rule with k colors and range r {n,k,{r_{1},r_{2},…,r_{d}}} d‐dimensional rule with neighborhood {n,k,{{off_{1}},{off_{2}},…,{off_{s}}}} rule with neighbors at specified offsets {n,k,rspec,s} order‐s rule {n,{k,1}} k‐color nearest‐neighbor totalistic rule {n,{k,1},r} k‐color ranger totalistic rule {n,{k,{wt_{1},wt_{2},…}},rspec} rule in which neighbor i is assigned weight wt_{i} {lhs_{1}>rhs_{1},lhs_{2}>rhs_{2},…} explicit replacements for lists of neighbors {fun,{},rspec} general function fun to apply to each list of neighbors bfun Boolean function to apply to collections of neighbors CellularAutomaton[rule] operator form of a rule <"key_{1}"val_{1},"key_{2}"val_{2},… > 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" n rule number "TotalisticCode" n totalistic code "OuterTotalisticCode" n outer totalistic code "GrowthCases" {g_{1},g_{2},…} make a cell 1 when g_{i} of its neighbors are 1 "GrowthSurvivalCases" {{g_{1},…},{s_{1},…}} 1 for g_{i} neighbors; unchanged for s_{i} "GrowthDecayCases" {{g_{1},…},{d_{1},…}} 1 for g_{i} neighbors; 0 for d_{i} "Dimension" d overall dimension "Colors" k number of colors "Range" r range of rule "Neighborhood" type neighborhood type  With "GrowthCases">{g_{1},g_{2},…}, a cell goes from value 0 to value 1 if it has g_{i} neighbors that are 1; otherwise it stays the same as before.
 With "GrowthSurvivalCases">{{g_{1},…},{s_{1},…}}, a cell goes from value 0 to value 1 if it has g_{i} neighbors that are 1, maintains value 1 if it has s_{i} neighbors that are 1, and otherwise gets value 0.
 With "GrowthDecayCases">{{g_{1},…},{d_{1},…}}, a cell goes from value 0 to value 1 if it has g_{i} neighbors that are 1, gets value 0 if it has d_{i} 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 "Rule90" 90 "Rule110" 110 "Code1599" {1599,{3,1}} "GameOfLife" {224,{2,{{2,2,2},{2,1,2},{2,2,2}}},{1,1}}  Common explicit forms for 2D cellular automaton rules include:

{n,{k,1},{1,1}} 9‐neighbor totalistic rule {n,{k,{{0,1,0},{1,1,1},{0,1,0}}},{1,1}} 5‐neighbor totalistic rule {n,{k,{{0,k,0},{k,1,k},{0,k,0}}},{1,1}} 5‐neighbor outer totalistic rule  The number of possible cellular automaton rules is as follows:

elementary rules 256 1D general rules 1D totalistic rules 2D general rules 2D 9‐neighbor totalistic rules 2D 5‐neighbor totalistic rules 2D 5‐neighbor 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 lhs_{i}>rhs_{i} 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 {r_{1},r_{2},…}, the list of neighbors is taken to be a full array with dimensions 2{r_{1},r_{2},…}+1.
 If the neighbors in a multidimensional cellular automaton are specified by an explicit list of offsets, the neighbors are supplied in a onedimensional 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 order‐s cellular automaton, specified by {rule,kspec,rspec,s}, each step depends on s preceding steps.
 Initial conditions are constructed from init as follows:

{a_{1},a_{2},…} explicit list of values a_{i}, assumed cyclic {{a_{1},a_{2},…},b} values a_{i} superimposed on a b background {{a_{1},a_{2},…},{b_{1},b_{2},…}} values a_{i} superimposed on a background of repetitions of b_{1}, b_{2}, … {{{{a_{11},a_{12},…},off_{1}}, {{a_{21},…},off_{2}},…},bspec} values a_{ij} at offsets off_{i} on a background {{a_{11},a_{12},…},{a_{21},…},…} explicit list of values in two dimensions {aspec,bspec} values in d dimensions with d‐dimensional 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 order‐s 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:

t all steps 0 through t {t} a list containing only step t {{t}} step t alone {t_{1},t_{2}} steps t_{1} through t_{2} {t_{1},t_{2},dt} steps t_{1}, t_{1}+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:

All all cells that can be affected by the specified initial condition Automatic all cells in the region that differs from the background 0 cell aligned with beginning of aspec x cells at offsets up to x on the right x cells at offsets up to x on the left {x} cell at offset x to the right {x} cell at offset x to the left {x_{1},x_{2}} cells at offsets x_{1} through x_{2} {x_{1},x_{2},dx} cells x_{1}, x_{1}+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 off_{t}.
 CellularAutomaton[rule][init] is equivalent to CellularAutomaton[rule,init].
Examples
open allclose allBasic Examples (3)
Scope (91)
OneDimensional Rules (26)
Generate the same result using RulePlot:
3color totalistic rule with code 867:
2color range (two neighbors on the left and one on the right) rule 23898:
Rule 30 specified by giving explicit offsets for cells in its neighborhood:
An analog of rule 30 with modified offsets:
Rule 30 specified by giving explicit weights for cells in its neighborhood:
Totalistic rules have weight 1 for each offset in the neighborhood:
A 3color outer totalistic rule:
Specify rule 90 by giving explicit replacements for neighborhoods:
Specify rule 90 by giving a single "algebraic" replacement rule:
Use an explicit Boolean formula for rule 30, operating on True and False states:
Values in a cellular automaton can be any symbolic expression:
Use an arbitrary symbolic function f as the rule to apply to range1 neighbors:
Apply the function to neighbors with offsets and :
Set up a "Pascal's triangle cellular automaton":
Specify rule 90 as an explicit function:
Additive cellular automaton modulo 4:
The second argument to the function is the step number:
Change the rule at successive steps; #2 gives the step number:
Use continuous values for cells:
Specify rule 90 as a pure Boolean function:
An analog of rule 90 specified using a pure Boolean function:
Rules Specified by Associations (5)
Initial Conditions (8)
Explicit initial conditions are assumed cyclic:
The left neighbor of the leftmost cell is the rightmost cell, and vice versa:
Start with a "seed" consisting of the block 11101 surrounded by 0s:
Start from a single 0 surrounded by 1s:
Start from 111 on a background of repeated 10 blocks:
Specify the "seed" as a sparse array:
Use a SparseArray to give the complete cyclic initial condition:
Time Steps (6)
Region Specifications (11)
By default, CellularAutomaton automatically cuts off the region not covered by the pattern:
Include all cells that could possibly be affected given the structure of the rule:
Include only the region that differs from the background:
Include all cells that could possibly be affected:
By default, different rules give regions of different widths:
Force all rules of the same type to give regions of the same width:
The region that can possibly be affected depends on the range of the rule:
Show only the region from cell 0 (the position of the initial 1) to cell 40:
Negative positions are on the left:
Give the region consisting just of cell 0 at each step:
Include only the value of cell 0, not in a list:
Show every other cell in time and space:
Cell 0 is always the leftmost cell in the explicit part of the initial condition:
Repeat a finite block to fill the region of initial conditions from positions to :
Multidimensional Rules (13)
Evolve range1 2D (9neighbor) totalistic code 14 for 2 steps:
Give only the result after 2 steps:
Show the result after 30 steps:
Show the mean color of each cell:
Show the spacetime history as a 3D image:
Show a cube at the position of each 1 cell:
A spacetime slice for 50 steps across all values at offset 0:
Mean colors of all cells with particular positions:
Use RulePlot to visualize the totalistic rule specification:
5neighbor outer totalistic rule:
Use RulePlot to visualize the outer totalistic rule specification:
Use an initial condition with two black cells, specified in a sparse array:
Multidimensional Rules Specified by Associations (8)
Specify 2D totalistic code 14 using an association (with a 9cell neighborhood assumed):
5neighbor totalistic code 26:
Describe the neighborhood using the string "VonNeumann":
5neighbor outer totalistic code 110:
Growth rule in which cells get value 1 when they have 1 or 2 neighbors (of 9) with value 1:
Growthdecay rule in which cells get value 1 when they have 1 or 2 neighbors with value 1, and get value 0 if they have 6 or 7 neighbors with value 1:
Rule in which cells get value 1 when they have 1 or 2 neighbors with value 1, keep their value if they have 6 or 7 neighbors with value 1, and get value 0 otherwise:
Rule in which cells get value 1 when they have 1 neighbor (of 7) with value 1:
Rule in which cells get value 1 when they have 1 neighbor (of 27) with value 1:
HigherOrder Rules (6)
Rule 30 written out explicitly as a "firstorder rule":
A secondorder analog of rule 30, involving two steps of initial conditions:
Include both initialcondition steps in the output:
Secondorder rule 1008, starting with a single 1 in both initial condition steps:
Include both steps in the initial conditions:
Secondorder totalistic rule 10 with 2 colors and range 1:
A order version of the same rule:
Rule 150R—the secondorder reversible mod 2 rule:
A spacetime slice of a secondorder totalistic rule with 2 colors and range 1:
Applications (23)
Make a color picture of rule 30:
Make pictures of the first 32 elementary cellular automata:
Show the 2color range2 totalistic code 20 cellular automaton from a sequence of initial conditions:
Show results for 3color range3 totalistic code 1599 for different initial conditions:
Pad with three 0s at the side of each pattern:
Show a single evolution in multiple "panels":
Make a "random" walk from the values of cells on the center column of rule 30:
Find repetition periods of rule 90 in cyclic regions of successive widths:
Draw the state transition graph for rule 110 in a region of size 7:
Generate a difference pattern for two cellular automata with initial conditions differing by one bit:
Show the common evolution in gray:
Use an outertotalistic 2D cellular automaton to generate a mazelike pattern:
Use a growth rule to generate an irregular pattern:
Show steps in the evolution of a 5neighbor outertotalistic 2D cellular automaton:
Show a "glider" in the Game of Life:
Show the evolution of the "puffer train" in the Game of Life:
The Game of Life from random initial conditions, averaged for 100 steps:
Patterns generated by a sequence of 2D 9neighbor rules:
Render a 3D view of a 2D cellular automaton evolution using spheres:
Show a sequence of steps in the evolution of a 3D cellular automaton:
Show time averages of slices at a sequence of heights in a 3D cellular automaton:
A cellular automaton based on multiplication of complex integers:
Properties & Relations (9)
Highlight the center column of cells:
Use RulePlot to generate graphics:
Image generates an image in which each cell is a single pixel:
steps of cellular automaton evolution give a list of length :
Initial conditions given as explicit lists are assumed cyclic:
The center cell starting from all possible tuples gives the digits in the rule number:
Here is a 5neighbor outer totalistic code:
Generate its RulePlot:
Possible Issues (7)
By default, the lists in each evolution are made only as long as they need to be:
Use {t,All} to get lists of the same length for all rules of a particular type:
If no cells ever differ from the background, the automatically selected region will always be empty:
Rules with alternating backgrounds can give lists which contain only 0s:
If the evolution is continued for 2 steps, explicit 1s are included in the 1step result:
In this form, a specification of the background is included:
By default, each evolution is made only as wide as it needs to be:
Use {t,All} to get consistent widths:
A 3color rule may generate only values 0 and 1:
If visualized with ArrayPlot, the value 1 will be shown black:
Use RulePlot to show colors correctly based on the underlying rule:
Explicit ColorRules also avoids the problem with default ArrayPlot:
Use RulePlot to show the underlying rule:
Cells and steps in CellularAutomaton are not numbered according to their part numbers:
Rule numbers have different meanings when the offsets are specified in different orders: