Cellular Automata

Mus270C Cellular Automata

• Discrete Dynamical System – Space and me • Dimension – 1-D, 2-D, … • States – Neighborhood and neighbors • Rules

2 1-D Cellular Automata

• Neighborhood

3 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

4 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

• Rules

5 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

• Rules

• Example t = 1

6 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

• Rules

• Example t = 1 t = 2

7 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

• Rules

• Example t = 1 t = 2

8 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

• Rules

• Example t = 1 t = 2

9 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

• Rules

• Example t = 1 t = 2

10 1-D Cellular Automata

• Neighborhood

• Black & White neighbors (States)

• Rules

• Example t = 1 t = 2

11

Every cell and its two neighbors will be one of the following types

Represent a black cell with 1 and a white cell with 0

1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0

Every yellow cell above can be filled out with a 0 or a 1 giving a total of 2 8=256 possible update rules. This allows any string of eight 0s and 1’s to represent a disnct update rule

Example: Consider the string 0 1 1 0 1 0 1 0 it can be taken to represent the update rule

1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0

Or equivalently

Now think of 01101010 as the binary expansion of the number 0 27+ 1 26+ 1 25+ 0 24+1 23+ 0 22+ 1 21+ 0 20 = 64+32+8+2=106. So the update rule is rule # 106 Rule #45=32+8+4+1 = 0 27+ 0 26+ 1 25+ 0 24+1 23+ 1 22+ 0 21+ 1 20 =0 0 1 0 1 1 0 1

Rule #30=16+8+4+2 = 0 27+ 0 26+ 0 25+ 1 24+1 23+ 1 22+ 1 21+ 0 20 =0 0 0 1 1 1 1 0

This is a naming convenon of the 256 disnct update rules by , New Kind of Science. Notable rules in this class include , , and . is also interesng because it creates Pascal's Triangle modulo 2. Rule 110 is known to be Turing complete. This implies that, in principle, any calculaon or computer program can be simulated using this automaton.

hp://en.wikipedia.org/wiki/Elementary_cellular_automaton Rule 30 Rule 90 Classes of cellular automata (Wolfram)

Class 1: aer a finite number of me steps, the CA tends to achieve a unique state from nearly all possible starng condions (limit points) Class 2: the CA creates paerns that repeat periodically or are stable (limit cycles) – probably equivalent to a regular grammar/finite state automaton Class 3: from nearly all starng condions, the CA leads to aperiodic- chaoc paerns, where the stascal properes of these paerns are almost idencal (aer a sufficient period of me) to the starng paerns (self-similar fractal curves) – computes ‘irregular problems’ Class 4: aer a finite number of steps, the CA usually dies, but there are a few stable (periodic) paerns possible (e.g. Game of Life) - Class 4 CA are believed to be capable of universal computaon Conway’s Game of Life

live dead

18 Conway’s Game of Life

live dead 1. Any dead cell with exactly three live neighbors comes to life.

19 Conway’s Game of Life

live dead 1. Any dead cell with exactly three live neighbors comes to life.

20 Conway’s Game of Life

live dead 1. Any dead cell with exactly three live neighbors comes to life.

21 22 23 CA in AthenaCL

• Standard: f{s} Discrete cell values, rules match cell formaons (neighborhoods) • Totalisc: f{t} Discrete cell values, rules match the sum of the neighborhood • Connuous: f{c} Real-number cell values within unit interval, rules specify values added to the average of previous cell formaon • Float: f{f} Like connuous, but implemented with floats (it makes a difference) CA in AthenaCL

• For f{s,t}: the k value provides the number of possible values • For f{c,f}: the k value is zero • r: number of neighbor cells taken into account (neighborhood = 2r+1) • x: size of CA space • y: number of generaons • sub-table is defined with width (w), center (c), and skip (s) • i: inializaon as center or random Examples

• auca f{s} 380 0 • auca f{s} 379 0 • auca f{t} 37 0 • auca f{t} 39 0 • auca f{c} .8523 0 • auca f{f} .254 0 • tpmap 100 cl,f{s},12,0,fria • auca f{s} 12 0 cl: use acve cell index posions to indicate acve posions of a scale C.1.17. caList (cl) fria: flatRowIndexAcve sra: sumRowAcve Example (cont.) emo m pin a 5@0|7@2,c2,c7 tmo ha n a 27 e d0 c,0 e d1 cl,f{s},30,0,fria,oc e d2 c,1 e d3 c,1 e r pt,(c,1),(c,1),(c,1),(c,1) Creang a direct mapping

• A common technique extracts two dimensional data from acve (non-zero) cells: table columns are treated as discrete pitch values, or a scale, and table rows are treated as discrete me steps. An acve cell is interpreted as an event with a pitch specified by the cell’s column; this pitch is sustained for as many rows as the specific column is acve.

e d1 cl,f{s},30,0,fria,oc e d2 cl,f{s},30,0,sra,oc e d3 cl,f{s},30,0,sra,oc tpmap 100 cl,f{s},30,0,fria,oc tpmap 100 cl,f{s},30,0,sra,oc See also

• F.1.20. script07a.py: The CA as a Generator of Melodies • F.1.21. script07b.py: The CA as a Generator of Rhythms Addendum: Sieve

• Residual class consists of two integer values, a modulus (M) and a shi (I): M@I • Logic operators are used to combine residual classes “|” OR, “&” AND, “^” XOR, “-” NOT

3@0 = [ . . . , –6, –3, 0, 3, 6, . . . ] 3@0 | 4@0 = [ . . . , 0, 3, 4, 6, 8, 9, 12, . . . ] 3@0 & 4@0 = [ . . . , 0, 12, 24, . . . ] 3@0 ^ 4@0 = [ . . . , –3, 3, 4, 6, 8, 9, 15, . . . ] Logic vs. Sets

• XOR: (¬P∧Q)∨(P∧¬Q) • Symmetric Difference: (A∩BC)∪(B∩AC) • Let A△B denote the symmetric difference of the sets A and B. Given an object x, x∈A△B⟺(x∈A) XOR (x∈B). • In general, one has a correspondence between statements in set theory and statements in logic, e.g. • x∈A∪B⟺(x∈A) OR (x∈B) • x∈A∩B⟺(x∈A) AND (x∈B) • x∈Ac⟺NOT (x∈A)