# Cellular Automata

AI and Robotics

Dec 1, 2013 (4 years and 5 months ago)

59 views

CELLULAR AUTOMATAS
RULES AND APPLICATIONS
MARIA LUISA MARTINEZ · FI UPM · MASTER CACI
COMPLEX SYSTEMS

CONTENT
1.CELLULAR AUTOMATA
2.SPECIFIC RULES
3.NATURAL CA-LIKE PHENOMENA & APPLICATIONS
4.LET’S PLAY: How to use it?
5.REFERENCES
1.CELLULAR AUTOMATA
 CELLULAR AUTOMATON (pl.), commonly
abbreviated CA.
 A CA is a dynamical system that is discrete in space
and time.
 A cellular automaton consists of a regular grid of
cells, each in one of a finite number of states, such
as on and off.
 All interactions all local, with the next state of cell
being a FUNCTION of the current state of itself and
its neighbors.
1.CELLULAR AUTOMATA
 Radius of a cell: r
 Neighborhood size: consists of total of 2r+1 cells, 2r+1 = N
 We will denote state of cell i at time t by c
i
(t)
 Number of states: k
 c
i
(t) = function (c
i-1
(t-1) , c
i
(t-1) , c
i+1
(t-1) )  left, right and
current cell.
ONE DIMENSIONAL CA
C
i-r
(t-1)
C
i-1
(t-1)
C
i
(t-1)
C
i+1
(t-
1)
C
i+r
(t-1)
C
i
(t)

SPACE
TIME
GENERAL CA PARAMETERS
1.CELLULAR AUTOMATA
ONE DIMENSIONAL CA
→ One possible rule table for a one-dimensional CA, with r=1 and k=2.
→ Last column contains the next state of the cell. Since there are 8 rows
in the table, there are 256 rule tables!!!!
1.CELLULAR AUTOMATA
TWO DIMENSIONAL CA
 Cellular automata are mathematical models for systems in
which many simple components act together to produce
complicated patterns of behavior.
 The extension to 2D is significant for comparisons with
many experimental results on pattern formation in physical
systems.
 Immediate applications include dendritic crystal growth,
reaction-diffusion systems, and turbulent flow patterns.
(The Navier-Stokes equations for fluid flow appear to admit
turbulent solutions only in two or more dimensions.)
1.CELLULAR AUTOMATA
 Wolfram´s CA Classification.
 Conway’s Game of Life.
TWO DIMENSIONAL CA
NW
N
NE
W
CELL
E
SW
S
SE
→ Next cell state = function(states of the nearest neighbors)
→ You can specify rules, in the same way as in 1D CA.
S(t+1)=F(S
j
(t); j € N
S, state
F, rule function
1.CELLULAR AUTOMATA
N DIMENSIONAL CA
2.SPECIFIC RULES
INITIAL CONDITIONS
To start with the updating of the cells of the CA we must specify
the initial state of the cells, the initial conditions or seed.
2.SPECIFIC RULES
1D CA RULES
N=3 neighborhood size (2 neighbors)
k=2 binary value range (two states on/off)
2
N
number of neighborhoods
R= k
k
N
number of different rules

→ The rule number R, is its decimal equivalent, which will
range from 00000000b to 1111111b, and R from 0 to 255.
→ At each time step, the value of a site at position is updated
according to the rule

2.SPECIFIC RULES
RULE 30
 1D CA
 00011110b  30
 Wolfram uses this rule in
Mathematica® for
creating random
integers.
2.SPECIFIC RULES
RULE 184
 1D CA
 THE TRAFIC RULE
 Each 1 cell corresponds to a vehicle, and each vehicle moves forwards
only if it has open space in front of it.

 RULE 184 is used as a simple model for traffic flow in a
single lane of a highway, and forms the basis for many CA
models of traffic flow more sophisticated.

2.SPECIFIC RULES
RULE 184
 THE TRAFIC RULE

2.SPECIFIC RULES
RULE FROMS AND EQUIVALENCES
2.SPECIFIC RULES
RULE FROMS AND EQUIVALENCES
2.SPECIFIC RULES
RULE 90
01011010b = 90 RULE
Rule 90 is also called the Sierpiński automaton, due to
the characteristic Sierpiński triangle shape it generates.
Each cell's new value is the exclusive or of the two
neighboring values.
RULE FUNCTION: s(t+1) = s_leftCell(t) XOR s_right(t)
RULE 110
01101110b = 110 RULE
Class 4 Wolfram Classification
Each cell's new value is a function or of the two
neighboring values and the current cell state.
RULE FUNCTION:
s(t+1) = [NOT(s_leftCell(t)) AND s_currentCell(t)] OR
[s_currentCell(t) XOR s_right(t)]
2.SPECIFIC RULES
SOME 1D SPECIAL RULES
RULE 51 (00110011)
COMPLEMENTARY
s(t+1) = NOT(s_currentCell(t))
RULE 170 (10101010)
LEFT SHIFT
s(t+1) = s_leftCell(t)
RULE 204 (11001100)
IDENTITY
s(t+1) = s_currentCell(t)
RULE 240 (11110000)
RIGHT SHIFT
s(t+1) = s_rightCell(t)
1D RULES
EXPLORATIONS:
2.SPECIFIC RULES
2D CA RULES

5 neighbor and simple
central seed:

9 neighbor and simple
central seed:
2.SPECIFIC RULES
2D CA RULES
2CA parameters
k = 2
4 neighbors and 1 active cell
N = 5
Number of rules
R = 2
2
5
= 1024
R = [0..1023]

10 binary digits
SEED: central cell of the grid.
Initial Rule: 452 (111000100b)
2D RULES
EXPLORATIONS:
1.NATURAL CA-LIKE PHENOMENA
 Lattice-gas CA
 The lattice-gas automaton is a model of how of gas or plasma
interacts in a local space.
 This model use local interactions (its nearest neighbors).

STATISTICAL MECHANICAL SYSTEMS
HPP simulation of gas flow. Source:
Wikipedia.org

1.NATURAL CA-LIKE PHENOMENA
 The Belousov-Zhabotinsky reaction (or B-Z)
 B-Z is a chemical reaction.
 Which oscillates towards a single equilibrium state, back and
forth between two such states, as a "chemical oscillator“.
 This model is a CA that produces spiral waves that resemble
those produced by the B-Z reaction. Similar spiral waves
observed in biochemical reactions.

AUTOCATALYTIC CHEMICAL SETS
Computer simulation of the
Belousov–Zhabotinsky reaction
occurring in a Petri dish. Source:
Wikipedia.org

1.NATURAL CA-LIKE PHENOMENA
GENE REGULATION
 1 gene can inhibit or activate another gene, which activates
a third an so on.
 Stuart Kauffman.
 Random Boolean Networks (RBNs) as models of biological
processes.
 Different rules for each cell, unlike the Wolfram CA, which had
cells that all have the same rule table.

1.NATURAL CA-LIKE PHENOMENA
MULTICELLULAR ORGANISMS
 At the heart of the growth of a multi-cellular organism is
the process of cellular division…
1.NATURAL CA-LIKE PHENOMENA

 COLONIES AND SUPER-ORGANISMS
 FLOCKS AND HERDS
 ECOSYSTEMS
 ECONOMIES AND SOCIETY
 IMAGE PROCESSING
 PARALLEL COMPUTATION
 Etc.

OTHER:
1.NATURAL CA-LIKE PHENOMENA

 An SDSS, is computer system for solving spatial problems.
 It is designed to assist the spatial planner in making land
use decisions.
 An SDSS usually exists in the form of a computer model,
including a land use model.
 Various techniques are available to simulate land use
dynamics,
 Cellular Automata (CA) based models
 Agent Based Models (ABM).
A SPATIAL DECISION SUPPORT SYSTEMS (SDSS)
MATRIX CA
The chess-board is the world; the pieces are the phenomena
of the universe; the rules of the game are what we call the
laws of Nature.
T. H. Huxley
4. LET’S PLAY
THE IDEA
①TO GENERATE THE MATRIX MOVIE SCREEN

4. LET’S PLAY
THE IDEA
 Possible states of cells: k = 256
0 black | 1 random range of green color (based on R,G,B)
② THE COLOR

pixel = color (R,G,B) ; R,G,B = 0..255
green = color (0, 0..255,0)
4. LET’S PLAY
SIMPLEST CASE: 1D CELLULAR AUTOMATA
 Possible states of cells: k = 256
 Neighborhood size (2 neighbors, r=1) N = 3
 Number of entries in the rule table: k
N
= 16777216
 Number of different rules: R= 2
k
N
=2
16777216
③ SIMPLE CELLULAR AUTOMATA 1D

④ NEIGHBORHOOD GEOMETRY

4. LET’S PLAY
SIMPLEST CASE: 1D CELLULAR AUTOMATA
 The initial state must be a random value for cells, which
some will be black an other will be in a random range of
green color.
⑤ INITIAL STATE OR SEED

4. LET’S PLAY
SIMPLEST CASE: 1D CELLULAR AUTOMATA
 Window size: 200 x 200 pixels
 Size of each cell: int scl = 20 pixels (this value can change)
 Number of cells in the window: 100
 For a different values of window and “scl” we obtain
different number of cells.
⑥ THE CA GEOMETRY

⑦ THE BOUNDARY CONDITIONS

 We are going to ignore edges that only have one neighbor
4. LET’S PLAY
SIMPLEST CASE: 1D CELLULAR AUTOMATA
 Is possible to use different rules.
 RULE 240 (11110000b) RIGHT SHIFT
 Current_cell(t+1) = left_cell(t)
⑧ THE RULE CONDITIONS

⑨ STOPPING CONDITION

 Repeatedly update all the cells of the CA, until some stopping
condition is met (for example, a pre-assigned number of steps
is attained, or the CA is in a quiescent state, or cycles in a
loop,...).
 When the height of the Window is achieved.
4. LET’S PLAY
SIMPLEST CASE: 1D CELLULAR AUTOMATA

RULE 240
scl = 20
RULE 30
scl = 2
RULE 240
scl = 4
RULE 90
scl = 10
SEED = CENTER
4. LET’S PLAY
2D CELLULAR AUTOMATA
 Possible states of cells: k = 256
0 black | 1 random range of green color (based on R,G,B)
② THE COLOR

 Neighborhood size: N = 3
 Number of entries in the rule table: k
N
= 16777216
 Number of different rules: R= k
k
N
=k
16777216
③ SIMPLE CELLULAR AUTOMATA 1D

④ NEIGHBORHOOD GEOMETRY

4. LET’S PLAY
2D CELLULAR AUTOMATA
 The initial state must be a random value for all the cells.
⑤ INITIAL STATE OR SEED

 Window size: 400 x 400 pixels
 Size of each cell: int scl = 2 pixels
 Number of cells in the window: 40000!!
⑥ THE CA GEOMETRY

⑦ THE BOUNDARY CONDITIONS

 We are going to consider all edges.
4. LET’S PLAY
2D CELLULAR AUTOMATA
for (int r=0; r<R; r++) {
for (int c=0; c<C; c++) {
int state = curr[r][c];
int lr = prev[r][(c-1+C)%C] + prev[r][(c+1)%C];
int ab = prev[(r-1+R)%R][c] + prev[(r+1)%R][c];

if (ab == 0) { //&0xff, bit mask to select the green color
curr[r][c] = (state+lr)&0xff; // adds new "life" to the ca
} else { //% es el resto, para no exceder nunca el valor de 255
curr[r][c] = (lr%tb)&0xff; // gives the "matrix"-y effect
}
⑧ THE RULE CONDITIONS

⑨ STOPPING CONDITION

 No stopping condition.
4. LET’S PLAY
2D CELLULAR AUTOMATA

4. REFERENCES
 Gary William Flake (1998). The Computational Beauty of Nature.
Computer explorations of Fractals, Chaos, Complex Systems and
 Ganguly, Niloy; Sikdar, Biplab K.; Deutsch, Andreas; Canright, Geoffrey;
Chaudhuri, P. Pal (December 2003), A survey on cellular automata, Tech.
Report, Centre for High Performance Computing, Dresden University of
Technology.
 Stephen Wolfram web page. available at:
http://www.stephenwolfram.com/

 Processing.org Wolfram tutorial. Available at:
http://processing.org/learning/topics/wolfram.html

 Processing 1.5.1. Java Reference.