<<

NAVY Research Group Department of Computer Science Faculty of Electrical Engineering and Computer Science VŠB-TUO 17. listopadu 15 708 33 Ostrava-Poruba Czech Republic!

Basics of Modern Computer Science

Cellular Automata An Introduction

Ivan Zelinka

MBCS CIPT, www.bcs.org/ http://www.springer.com/series/10624

Department of Computer Science Faculty of Electrical Engineering and Computer Science, VŠB-TUO 17. listopadu 15 , 708 33 Ostrava-Poruba Czech Republic www.ivanzelinka.eu Topics

• Historical overview • Introduction • CA’s and its rules • Wolfram’s classes of CA • Langton’s λ-parameter • CA’s behavior • Patterns • New Kind of Science • CA’s in simulation and modelling

2! navy.cs.vsb.cz! Objectives

The objectives of the lesson are: • Explain basics of CA’s • Show that CA’s produce different behavior and patterns • Explain rules of CA and its impact on its dynamics • Show that CA can be used as a pseudorandom number generator • Explain classification of CA’s by Wolfram’s classes 1 – 4 • Demonstrate use of CA’s in modeling and simulations

3! navy.cs.vsb.cz! Cellular Automata Introduction

Simple rules can lead to complex behavior.

4! navy.cs.vsb.cz! Cellular Automata Introduction

• 40's and 50s: von Neumann, Ulam: basic formalism (the study of self-reproduction) • 1970: The Conway: The Game of Life, an article in Scientific American (Gardner), it attracted big attention • 1983 Wolfram: A review of the CA, CA beginning of study in physics • 1984: Founding of Santa Fe Institute • 1987: The Langton: Artificial Life

5! navy.cs.vsb.cz! Cellular Automata Introduction

• Application – Pattern formation – Growth and decay organisms – Earth Sciences – Chemistry – Physics – Social systems

6! navy.cs.vsb.cz! Cellular Automata Introduction

• System modeling - from the bottom - individuals, local interactions (examples predator - prey population) • Agent based modeling (ABM) - agent-based modeling • WHY cellular automata (CA)? • Predecessor ABM: – Historically and technically simple but interesting – Several interesting models

7! navy.cs.vsb.cz! Cellular Automata Introduction

• CA – Discreet space and time – Strictly local interactions

• Classical mathematics – Continuous space and time – Solutions are global (cf PDE)

8! navy.cs.vsb.cz! Cellular Automata Introduction

• Discreet area – the grid of all cells • Homogeneity - all the cells are identical • Discrete states - each cell can have only finite number of states • Local interactions - status of the cells used only on the state of the surrounding area • Discreet dynamic - state changes synchronized in a discrete way

9! navy.cs.vsb.cz! Cellular Automata Introduction

lace of cells, with state

2 1 0 0 0 0 3 0 0 1 CA generaons 0 1 0 2 1 0 1 0 0 2

0 0 1 2 1 0 0 3 2 1 ...... 0 0 2 3 2 0 1 2 3 2

2 0 1 3 2 1 0 0 3 1 neighbourhood of a cell t t + 1

0 0 0 1 0 2

transion 0 0 0 0 0 1 2 3 table ...... 0 0 0 0 2 3 neighbourhood output

10! navy.cs.vsb.cz! Cellular Automata Introduction

• Grid / lattice / array of Nd identical cells (usually a rectangular grid) • Identical behaviors and connection patterns – 1D,2D,3D,... – one-dimensional – two-dimensional: rectangular, hexagonal, multidimensional ... • each cell has a neighborhood – n cells: itself, + the adjoining cells it is connected to • for 1D CAs, n = 2r + 1, r = “radius” • for 2D CAs, n = (2r + 1)2, r = “box range”

Moore von Neumann neighbourhood neighbourhood

11! navy.cs.vsb.cz! Cellular Automata Introduction

• Strict requirements for transition functions receive special class CA: – Legal - maintaining the steady state + symmetry – Totalistic - transition function works only with the sum of the values from the environment – Outer-totalistic additive - determines the state of the cell and the sum of the other – Additive - linear function (modulo k) over the values from the environment

12! navy.cs.vsb.cz! UTB ve Zlín, FT, Institut ízení proces a aplikované informatiky 14

generaci. Z obrázku je již patrné, jak dostalo své jméno napíklad pravidlo 110, Wolframem oznaováno jako „rule 110 CA“. pravidlo 110.[4]

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 1 1 0 UTB ve Zlín, FT, Institut ízení proces a aplikované informatiky 14 Cellular Automata Introduction 0 1 1 0 1 1 1 0 = 110 generaci. Z obrázku je již patrné, jak dostalo své jméno napíklad pravidlo 110, [4] Wolframem oznaováno jako „rule Obr.110 CA“.2. Pravidlo pravidlo 110 110.

Pravidla1 1 1 jednozna1 1 0n charakterizují1 0 1 1 0novou0 generaci0 1 1 bun0k,1 0 definujíce0 0 ji1 na 0 základ0 0 0 1 1 0 1 1 1 0 pedchozího stavu. Pi vytváení další generace dochází k prostému porovnávání aktuálního stavu buky a jejích soused s pravidly a pi shod se akceptuje stav pro konkrétní buku tak, jak pravidlo definuje. Je-li buka neaktivní a její oba sousedé jsou 0 1 1 0 1 1 1 0 = 110 aktivní, pak podle pravidla 110 bude buka v nové generaci aktivní. Obr. 2. Pravidlo 110 Zápis nkterých pravidel lze ješt zjednodušit, jako napíklad pravidlo 90 Pravidla jednoznan charakterizují novou generaci bunk, definujíce ji na základ 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 pedchozího stavu. Pi vytváení další generace dochází k prostému porovnávání 0 1 0 1 1 0 1 0 aktuálního stavu buky a jejích soused s pravidly a pi shod se akceptuje stav pro konkrétní buku tak, jak pravidlo definuje. Je-li buka neaktivní a její oba sousedé jsou aktivní, pak podle pravidla 110 bude buka v nové generaci aktivní. 0 1 0 1 1 0 1 0 = 90

Zápis nkterých pravidel lze ješt zjednodušit,Obr. 3. Pravidlo jako nap 90 íklad pravidlo 90 jež1 lze1 1vyjád1it pom1 0ocí rovnice1 0 1 a t1 1 0a t 0 a t 0mod1 12 , kde0 t1 zna0í itera0 0ní 1krok, 0 i-1,0 i+10 0 1 0 i 1 i1 i1 1 0 1 0 jsou sousedé buky a operátor modulo 2 koriguje13! rozsah opt do binárních hodnot. Tentonavy.cs.vsb.cz ! zápis vede k jednoduššímu výpotu a tedy urychlení iterací.[4]

0 1 0 1 1 0 1 0 = 90 Pi grafické interpretaci elementárních bunných automat se s oblibou využívá rozšíení do dvou-dimenzionálního prostoru,Obr. nebo 3. Pravidlolze takto 90 zachytit nkolik po sob jdoucích generací. t1 t t jež lze vyjádit pomocí rovnice ai ai1 ai1 mod 2 , kde t znaí iteraní krok, i-1, i+1 jsou sousedé buky a operátor modulo 2 koriguje rozsah opt do binárních hodnot. Tento zápis vede k jednoduššímu výpotu a tedy urychlení iterací.[4]

Pi grafické interpretaci elementárních bunných automat se s oblibou využívá rozšíení do dvou-dimenzionálního prostoru, nebo lze takto zachytit nkolik po sob jdoucích generací.

Cellular Automata UTB ve Zlín, FT, Institut ízení procesIntroduction a aplikované informatiky 15

0 0 0 1 1 1 1 0 = 30 0 1 0 1 1 0 1 0 = 90

! Time 1 0 0 1 0 1 1 0 = 150 1 1 1 1 1 0 1 0 = 250

Obr. 4. Grafická implementace generací

2.1.2 Obecné jednorozmrné automaty14! navy.cs.vsb.cz!

Mezi jedno-dimenzionální automaty ale nepatí pouze ty elementární. Je zejmé, že doposud uvažované parametry automatu jsou velmi limitující. Pi jejich rozšiování má smysl uvažovat jednak o zvýšení potu možných stav samotné buky, tak rozšíení okolí, které bude bráno v potaz pi vyhodnocování stavu v nové generaci. Takto bohatý prostor pro volbu parametr umožuje vytvoit nekonen velkou množinu jedno-dimenzionálních automat což ovšem klade nemalé požadavky na systém zápisu pravidel. Ze zápisu musí být patrné, jakého potu stav mže buka nabývat a jak velké je okolí, které hraje roli pi vyhodnocování.[9]

Za pedpokladu, že okolí bude shodn velké na obou stranách je možná jednoznaná definice jedinou cifrou a celý systém zápisu pak mže vycházet z již známého konceptu užitého u elementárních automat.

Napíklad konstrukce zápisu pravidla pro buku, za jejíž sousedy se považují všechny do vzdálenosti 1, buka má tedy 2 sousedy, jednoho vlevo a jednoho vpravo, mající ti možné stavy (0, 1, 2) bude následující.

Cellular Automata (3) CellularCellular Automata Automata (3) Introduction •cell i at time t is in one of a finite set of k states si,t ∈Σ •cell i at time t is in one of a finite set of k states si,t ∈Σ –often binary, Σ = { 0, 1 }, k = 2 –often binary, Σ = { 0, 1 }, k = 2 • Cell i at time t is in one of a finite set of k states s ∈ Σ n –the state of i ’s neighbourhood at timei,tnt is η ∈Σ –the –st aOftente of binary,i ’s ne ighbourhoodΣ={0,1}, k=2 at timet is ηi,t ∈Σ i,t – The state of ith neighbourhood at time i is η ∈ Σn •• sstatetate transition transition rule rule i,t • State transition nrule – update rule φ : Σ →Σn – update– updaterule rule φφ: :Σ Σn→Σ →Σ n •for a k state, n neighbourhood CA, there are k k possible rules • For a k state, n neighbourhood CA, there are k k n possible rulesk n •f–torh ae rke state,are 256 differentn neighbourhood k = 2, r = 1 ( nCA,= 3) 1Dthere CAs are k possible rules – There are 256 different k = 2, r = 1 (n = 3) 1D CAs –t• heexhaustivere are enumeratio 256 differentn is possible k = 2, r = 1 (n = 3) 1D CAs – Exhaustive enumeration2 9 512 is154 possible –there• areexhaustive 2 = 2 ~enumeratio 10 differentn is kpossible= 2 , r = 1 (n = 9) 2D CAs – There are 2 29 = 2512 ~ 10154 different k = 2 , r = 1 • of which “the Game9 of Life” is one! (n–t = h9)e r2De aCAsre of2 2which= 2 “the512 ~Game 10154 ofdifferent Life” is one! k = 2 , r = 1 (n = 9) 2D CAs • array of state transition machines • Array of state• o ftransition which “the machines Game of Life” is one! – each– timestep,Each timestep update, update state state of ofevery every cell cell in in parallel: parallel: s(it ,1)+ = φ ()ηit, • array of state transition machines

Department– of Computereach Science timestep, updateNSC -- CAsstate -- 5 of every cell in parallel:sit,1+ = φ ()ηit, 15! navy.cs.vsb.cz!

Department of Computer Science NSC -- CAs -- 5 Cellular Automata Falling off the edge of the world

• Infinite grid – “grow” the grid as a pattern propagates • Finite grid – A hard boundary • edge cells with a fixed state (usually zero) – Periodic boundary conditions – calculate the index of the neighbours modulo N, size of grid • 1D ring • 2D ring • Equivalent to an infinite grid of repeating Nd tiles • Or weirder topologies, with a “twist”: Mobeuis bands, Klein bottles

0 1 2 3 4 = ... 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 ...

16! navy.cs.vsb.cz! Cellular Automata 1D CA rule numbers

• How to refer to the rules – enumerate all kn possible neighbourhood states, in (big- endian) numerical order – show the resulting value of each state – interpret the resulting string as a base k number • k = 2, r = 1 (n = 3) example: 111 110 101 100 011 010 001 000 0 0 1 0 1 0 1 0 = rule 42 • For larger (k, n), the rule number is usually given as a base - k string, rather than being converted to base ten – k = 3 , r = 1 (n = 3) example rule: 211000122121012200112021200

17! navy.cs.vsb.cz! Cellular Automata General 1D CA

• Construction writes rules for cells in which the neighbors are considered allUTB within ve Zlín 1,, theFT, Institut cell has ízení therefore proces a aplikované two neighbors, informatiky one left and one 16right, having three possible states (0, 1, 2) is as follows.

2 2 2 2 2 1 2 2 0 2 1 2 2 1 1 2 1 0 2 0 2 2 0 1 2 1 2 1 2 0 0 1

2 0 0 1 2 2 1 2 1 1 2 0 1 1 2 1 1 1 1 1 0 1 0 2 0 2 2 1 0 2 0 0

1 0 1 1 0 0 0 2 2 0 2 1 0 2 0 0 1 2 0 1 1 0 1 0 1 2 1 2 1 1 0 1

0 0 2 0 0 1 0 0 0 2 0 0

• The rule is then 1 / 212120010221020012121101200Obr. 5. Konstrukce obecných pravidel

Výsledné pravidlo se potom tedy zapíše takto:

1/212120010221020012121101200 18! navy.cs.vsb.cz!

kde lomítkem oddlená jednika znaí velikost okolí, z nejvyššího ísla v pravidle se jednoduše odvodí poet stav buky. Je dobré poznamenat, že pi potu stav nad deset je nutné oznaení písmeny (10=A, 11=B, …) nebo pozice íslice v pravidle je pesn dána a nelze tedy bez jasného vyznaení užít dvou a víceciferných ísel v pravidle. Za upozornní také stojí skutenost, že pravidla pro tyto automaty nelze nikterak decimáln zkracovat. Zápis pravidla 110 z píkladu výše má ekvivalent 1/01101110.

Pvodní pedpoklad symetrického okolí zdánliv ubírá na obecnosti, Ve skutenosti je pouze nutné si uvdomit, že z jakkoli nekonzistentního okolí lze symetrické jednoduše vytvoit a pravidla snadno pizpsobit tak aby vyhovovala zadaným podmínkám.

2.1.3 Praktické aplikace jednorozmrných bunných automat

Zcela konkrétní praktickou aplikací je generátor náhodných ísel využitý v programu Mathematica pro generování celoíselných náhodných hodnot.

Další zajímavá aplikace, jedno-dimenzionálních bunných automat je v oblasti kryptografie. Pro oba zmiované pípady je velice pínosné zejména pravidlo 30, jímž generovaná bitová sekvence spluje všechny statické testy náhodnosti. Následující ukázka osvtlí principy využití bunných automat v oblasti šifrování.[6]

Cellular Automata k=2 CAs with Boolean Rules

• k = 2, r = 1 (n = 3) example: 111 110 101 100 011 010 001 000 0 0 1 0 1 0 1 0 = rule 42 • For larger (k, n), the rule number is usually given as a base - k string, rather than being converted to base ten

• Label the three sites s-1s0s1 • Take 0 is false and 1 is true • Then the rule can be expressed as (¬s0 ∧s1)∨(¬s-1 ∧s1) • the 256 CA rules correspond to the 256 boolean • functions of three variables

19! navy.cs.vsb.cz! Cellular Automata 1D1D CAs

•tim• e Timedisp ldisplayay – draw– tDrawhe generations the generations one oneunder under the theother other

t 0 0 0 1 1 1 0 0 0 0 t + 1 0 0 0 1 0 1 0 0 0 0 t + 2 0 0 1 1 0 1 1 0 0 0 ... • Wolfram restricts “legal” CAs to • Wolfram– quiescent restricts rules “legal” CAs to – quiescent• identify rules a special “quiescent” state (conventionally the 0 state) → • identify• then, a special no “spontaneous “quiescent” generation” state (conventionally : always have 000 the 0 0state) – reflectionally symmetric rules : no preferred handedness • then, no “spontaneous generation” : always have 000 → 0 • abc and cba have same transition rule – reflectionally symmetric rules : no preferred handedness • abc and cba have same transition rule

Department of Computer Science NSC --20 CAs! -- 9 navy.cs.vsb.cz! all the 32 “legal” 1D k=2, r=1 CAs

Cellular Automata • http://www-course.cs.york.ac.uk/nsc/applets/CellularAutomata/index1d.html all the 32 “legal” 1D k=2, r=1 CAs • random start state

[Wolfram 1994, p16]

21! navy.cs.vsb.cz! Department of Computer Science NSC -- CAs -- 10 Cellular Automata totalistic rules

• next value of a site depends only on the sum of the values of its neighborhood, not their individual values – For binary, k=2, rules, this reduces to the total number of “live” sites in the neighborhood – For a k state, n neighborhood CA, there are kn(k−1)+1 possible totalistic rules • there are 16 different k = 2, r = 1 (n = 3) totalistic 1D CAs • there are 210 = 1024 different k = 2 , r = 1 (n = 9) totalistic 2D CAs – “outer totalistic” rules • next value of a site depends on the sum of the values of its outer neighborhood, and on the central site – “the Game of Life” is outer totalistic • totalistic rules encompass all four Wolfram classes of • CA behaviors (later)

22! navy.cs.vsb.cz! Cellular Automata CA totalistic code numbers

• How to refer to totalistic rules – enumerate all n(−1)+1possible sums of neighborhood states, in (big- endian) numerical order – show the resulting value of each state – interpret the resulting string as a base k number • k=2, n=3 example: 3 2 1 0 0 1 1 0 = code 6 • Similar encoding scheme for outer totalistic rules

23! navy.cs.vsb.cz! Cellular Automata changing the initial state, 1D, k=2,r=2 changing the initial state, 1D, k=2,r=2

10

12

24

52

totalistic codes 2 sites 10 sites other random changed changed random [Wolfram 1994, p124]

Department of Computer Science NSC -- CAs -- 13

24! navy.cs.vsb.cz! Cellular Automata Multidimensional Rules

• Evolve range-1 2D (9-neighbor) totalistic code 14 for 2 steps: – CellularAutomaton[{14, {2, 1}, {1, 1}}, {{{1}}, 0}, 2]

0, 0, 0, 0, 0 , 0, 0, 0, 0, 0 , 0, 0, 1, 0, 0 , 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0 , 0, 1, 1, 1, 0 , 0, 1, 1, 1, 0 , 0, 1, 1, 1, 0 , 0, 0, 0, 0, 0 , 1, 1, 1, 1, 1 , 1, 0, 0, 0, 1 , 1, 0, 0, 0, 1 , 1, 0, 0, 0, 1 , 1, 1, 1, 1, 1 888 < 8 < 8 < 8 < 8 << 88 < 8 < 8 < 8 < 8 << 88 < 8 < 8 < 8 < 8 <<<

25! navy.cs.vsb.cz! Cellular Automata Multidimensional Rules

• 5-neighbor totalistic rule – ArrayPlot[ CellularAutomaton[{26, {2, {{0, 1, 0}, {1, 1, 1}, {0, 1, 0}}}, {1, 1}}, {{{1}}, 0}, {{{100}}}]]

26! navy.cs.vsb.cz! Cellular Automata Multidimensional Rules

• 5-neighbor outer totalistic rule – ArrayPlot[ CellularAutomaton[{110, {2, {{0, 2, 0}, {2, 1, 2}, {0, 2, 0}}}, {1, 1}}, {{{1}}, 0}, {{{100}}}]]

27! navy.cs.vsb.cz! Cellular Automata 3D Automata

28! navy.cs.vsb.cz! Cellular Automata 3D Automata

29! navy.cs.vsb.cz! Cellular Automata Wolfram’s 4 classes of CA behavior

• Class1: long term behavior is all the same, independent of initial state. Nearly all initial patterns evolve quickly into a stable, homogeneous state. Any randomness in the initial pattern disappears. • Class2: long term behavior is dependent on limited neighborhood, periodic behaviors, with periods << kN . Nearly all initial patterns evolve quickly into stable or oscillating structures. Some of the randomness in the initial pattern may filter out, but some remains. Local changes to the initial pattern tend to remain local.

30! navy.cs.vsb.cz! Cellular Automata Wolfram’s 4 classes of CA behavior

• Class3: long term behavior is chaotic, dependent on ever- increasing neighborhood, any periodic behavior determined by grid size : periods ~ kN . Nearly all initial patterns evolve in pseudo- random or chaotic manner. Any stable structures that appear are quickly destroyed by the surrounding noise. Local changes to the initial pattern tend to spread indefinitely.

31! navy.cs.vsb.cz! Cellular Automata Wolfram’s 4 classes of CA behavior

• Class4: long term behaviors include long-lived complex structures. Nearly all initial patterns evolve into structures that interact in complex and interesting ways, with the formation of local structures that are able to survive for long periods of time. Class 2 type stable or oscillating structures may be the eventual outcome, but the number of steps required to reach this state may be very large, even when the initial pattern is relatively simple. Local changes to the initial pattern may spread indefinitely. Wolfram has conjectured that many, if not all class 4 cellular automata are capable of universal computation. This has been proven for Rule 110 and Conway's game of Life. Value at a given site is not determined by anything simpler than the CA evolution – unpredictable or “incompressible” behavior.

32! navy.cs.vsb.cz! Úvod Teorie Studium CA Aplikace Souvislosti

Wolframova klasifikace Cellular Automata Po5ty pravidelWolfram’s v jednotliv 4 classes=ch of tCA:ídách behavior

33! navy.cs.vsb.cz! Cellular Automata Langton’s λ-parameter

• Wolfram’s classes are not mathematically defined – difficult to reason about • Langton’s λ derived from statistic of the rule table

– let n0 be number of rule table entries that result in quiescent state 0

n λ = 1− 0 k n – If λ = 0, all the transitions are to the quiescent state – If λ = 1, no transitions to quiescent state – For k = 2, λ = 0.5, half the transitions are quiescent, half are not

34! navy.cs.vsb.cz! Cellular Automata Langton’s λ-parameter

• Claimed relationship betweenλand Wolfram’s 4 classes – increasing λ corresponds to classes 1, 2, 4, 3 in that order – with critical “edge of chaos” λ corresponding to class 4

1! 3!

2! 4!

35! navy.cs.vsb.cz! Cellular Automata Some Class 1 Behaviour

36! navy.cs.vsb.cz! Cellular Automata Some Class 2 Behaviour

37! navy.cs.vsb.cz! Cellular Automata Some Class 3 Behaviour

38! navy.cs.vsb.cz! Cellular Automata Some Class 4 Behaviour

39! navy.cs.vsb.cz! Cellular Automata Is λ a good measure?

• Results based on “average” behavior – good correlation between λ and other interesting properties for extreme values of λ, near 0 and 1 – but not so good for intermediate values • Near the claimed interesting complex class 4 behaviors • There is no “average behavior” for intermediateλ – there is a great deal of variation – this kind of averaging over simple rule table properties does not seem to capture the full complexity of the situation

40! navy.cs.vsb.cz! Cellular Automata moremore realistic realistic measures measures

•• aAnalysenalyse thethe embedded embedded coherent coherent structures structures –– eExample:xample: rulerule 18 18

classicalclassic aspace-timel space-time diagram, diagram, samesame rule,rule, withwith diagram diagram filtered filtered apparentlyapparently “chaotic”, “chaotic”, class 3 classto expose 3 to exposeunderlying underlying structure structure M. Mitchell. Computation in Cellular Automata. In Non-Standard Computation. Springer, 1998.

Department of Computer Science NSC --41 CAs! -- 19 navy.cs.vsb.cz! Department of Computerof ScienceDepartment • • • e s C finite), and an previously-seen state (the space is space: – – –… – – tate space is of size of is space tate ventually a trajectory encounters A rules define a trajectory through this t merge S S S he trajectory leading to the attractor is a is attractor the to leading trajectory he i i i-1

→ may have no pre-images : “ : pre-images no have may may trajectories : pre-images several have may is a is S

i-1 pre-image → basins of attraction S i

→ attractor cycle attractor S i+ 1 of → S … i k ,

Cellular Automata N S -Cs- 20 -- CAs NSC -- d Basins of AttractionS i+1

is the is Garden of Eden

• State space is of size k^N^d is formed is

• CA rules define a trajectory through thissuccessor space:

– … → Si-1 → Si → Si+1 → ...

– Si-1 is a pre-image of Si , Si+1 is the successor of Si

– Si may have several pre-images : trajectories may merge transient

– Si may have no pre-images : “Garden of Eden” state (1) ” state ” • Eventually a trajectory encounters a previously-seenof state (the state

space is finite), and an attractor cycleS is formed i – The trajectory leading to the attractor is a transient

42! navy.cs.vsb.cz! Cellular Automata Basins of Attraction

• An attractor, plus the transitive closure of all its pre-images, forms basin of attraction – the trajectory from every state in the basin ends up on the attractor • The basin of attraction field contains all the basins of attraction, and basinsso all k^N^d of states attraction (2) – this depends on the size of the CA as well as the CA rule • an attractor, plus the transitive closure of all its pre-images, forms a basin of attraction – the trajectory from every state in the basin ends up on the attractor •the basin of attraction field contains all the basins of attraction, 43! navy.cs.vsb.cz! and so all kNd states – this depends on the size of the CA as well as the CA rule

Department of Computer Science NSC -- CAs -- 21 Cellular Automata basinsBasins of attraction of Attraction (3)

•r• ulrulee 16, 16, k k = = 7, 7, N N == 1616 16 –2– 162 = 65536= 65536 states, states, 89 89 basins basins of attraction of attraction (11 non-equivalent) (11 non-equivalent)

http://www.cogs.susx.ac.uk/users/andywu/gallery/ddlab_gallery.html 44! navy.cs.vsb.cz!

Department of Computer Science NSC -- CAs -- 22 Cellular Automata Reversible CAs

• If a CA has merging trajectories, it can’t “run backwards” • A reversible CA is easy to construct – in contrast to the conventional update rule

si,t+1 = φ(ηi,t) consider si,t+1 = φ(ηi,t) − si,t−1 (subtraction modulo k)

– rearranging gives si,t-1 = φ(ηi,t) − si,t+1 – so this rule is reversible, for any function φ – it can be recast in the conventional form, if desired • No merging trajectories – no transients, all states on a cycle (“ergodic”) • Reversible CAs are useful for : – modelling reversible laws of physics – exploring reversible computation, c.f. quantum computation

45! navy.cs.vsb.cz! Cellular Automata Self-replicating CAs

• von Neumann’s self-replicating CA – 1950s – 29 states – “von Neumann” neighbourhood • Langton’s self-replicating loops – http://necsi.org/postdocs/sayama/sdsr/java/ • Is universal computation possible?

46! navy.cs.vsb.cz! Cellular Automata Conway’s “Game of Life”

• Mesh network of cells, the neighbors are calculated and the diagonal • Each cell is in one of two states: alive, dead • Played in iterations • If the cell is alive: – less than two neighbors ⇒ dying of loneliness – more than three neighbors ⇒ dies of overpopulation – two / three neighbors ⇒ survives • If the cell is dead: – exactly three neighbors ⇒ comes alive – or remains dead

47! navy.cs.vsb.cz! Cellular Automata Conway’s “Game of Life”

– original “game” was played with pieces on a Go board – a 2D, k=2, r=1 (n=9) CA • Rules of Life – next state depends on: the sum of the 8 neighbour cell states, and on the state of the central cell (“outer totalistic”)

! !

#n \ si,t 0 1 ! ! ! ! #n ∉ {2, 3} < 2 0 0 dies of “loneliness” 1 ! ! ! ! 2 0 1 “survives” ! ! ! ! 3 1 1 “born” / ““survives” ! ! ! ! > 3 0 0 dies of “overcrowding” #n = 3 0

48! navy.cs.vsb.cz! Cellular Automata Still Life “Still Life” • A stable, unchanging pattern •a stable, unchanging pattern

–block pond

–beehive hat

–loaf spiral

– many more at: • http://www.ericweisstein.com/encyclopedias/life/topics/StillLifes.html

Department of Computer Science NSC -- CAs -- 26 49! navy.cs.vsb.cz! Cellular Automata • a pattern that movesGlider constantly across the grid • A pattern that moves constantly across the grid – after– 4a generationsfter 4 generations the original pattern the is reproduced original one pattern cell further to the rightis andreproduced one cell further one down cell further right and one cell further down

http://www.math.com/students/wonders/life/life.html

navy.cs.vsb.cz! http://www.cogs.susx.ac.uk/users/an50! dywu/gallery/ddlab_gallery.html

Department of Computer Science NSC -- CAs -- 27 Cellular Automata the rthe - r -pentomino pentomino

• exhaustive• Exhaustive study study of of all all connected connected 5 cell initial 5 statescell initial states

• All are relatively uninteresting (die quickly or become Still Life), except the r – pentomino • all relatively– runs 1103 uninteresting steps, by when it becomes (quickly 6 gliders,8 die blocks,4 or beehives,become 4 Still Life), exceptblinkers, for 1 ship, the 1 boat, r and-p 1 eloafn tomino – http://www.math.com/students/wonders/life/life.html

–runs 1103 steps, by when it has51! become 6 gliders, 8 blocks,navy.cs.vsb.cz ! 4 beehives, 4 blinkers, 1 ship, 1 boat, and 1 loaf

Department of Computer Science NSC -- CAs -- 28 Cellular Automata Propagating Structures

• Glider – emits regular stream of gliders • – continual growth, leaving behind “pollution” • Space filler – grows as fast as possible

52! navy.cs.vsb.cz! Cellular Automata Game of Life – Static Patterns

UTB ve Zlín, FT, Institut ízení proces a aplikované informatiky 23

Block Beehive Ship Boat Tub

Scorpion Sesquihat PaperClip

Obr. 12. Statické útvary

Druhou skupinu tvoí takzvané oscilátory. Jsou to objekty, které se s pravidelnou periodou 53! navy.cs.vsb.cz! pes nkolik stav vrací do pvodní konfigurace.

Toad Beacon Why Not Fore And Back

Light Bulb Laputa Quadpole

Obr. 13. Oscilátory

UTB ve Zlín, FT, Institut ízení proces a aplikované informatiky 23

Block Beehive Ship Boat Tub

Scorpion Sesquihat PaperClip CellularObr. 12. StatickéAutomata útvary Druhou skupinu tvoí takzvanéGame oscilátory. of Life Jsou - toOscilators objekty, které se s pravidelnou periodou pes nkolik stav vrací do pvodní konfigurace.

Toad Beacon Why Not Fore And Back

Light Bulb Laputa Quadpole

Obr. 13.54 Oscilátory! navy.cs.vsb.cz!

UTB ve Zlín, FT, Institut ízení proces a aplikované informatiky 24

Tetí podskupinu tvoí útvary, které se v njakém smru po ploše pohybují. Patí mezi n spaceships (vesmírné lod) s ortogonálním pohybem a gliders (kluzák) s pohybem UTB ve Zlín, FT, Institut ízení proces a aplikované informatiky 24 diagonálním.

Cellular Automata Tetí podskupinu tvoí útvary, které se vGame njakém smof ruLife po ploše – Moving pohybují. Pat Structuresí mezi n spaceships (vesmírné lod) s ortogonálním pohybem a gliders (kluzák) s pohybem diagonálním.

Glider HWSS spaceship

Obr. 14. Pohybující se útvary

Puffer je také útvar, který se v prostoru pohybuje obdobn jako spaceship, rozdílem je skutenost, že pi svém pohybu za sebou zanechává další žijící buky. Prvním známý útvar Glider HWSS spaceship tohoto druhu byl objeven Billem Gosperem kolem roku 1971. Obr. 14. Pohybující se útvary

Puffer je také útvar, který se v prostoru pohybuje obdobn jako spaceship, rozdílem je skutenost, že pi svém pohybu za sebou zanechává další žijící buky. Prvním známý útvar tohoto druhu byl objeven Billem Gosperem kolem roku 1971.

Puffer train

Obr. 15. Puffer

Spacefiller je jakýkoli útvar,55! který se s kvadratickou rychlostí rozrstánavy.cs.vsb.cz do prostoru,! který zapluje. První píklad takového útvaru byl nalezen Hartmutem Holzwartem v roce 1993. Puffer train

Obr. 15. Puffer

Spacefiller je jakýkoli útvar, který se s kvadratickou rychlostí rozrstá do prostoru, který zapluje. První píklad takového útvaru byl nalezen Hartmutem Holzwartem v roce 1993.

Cellular Automata

UTBGame ve Zlín, FT, Institutof Life ízení proces – Growinga aplikované informatiky Structures 25

Spacefiller

Obr. 16. Spacefiller

Velmi specifické jsou konfigurace takzvaných dl, kteí v pravidelných cyklech chrlí do 56! navy.cs.vsb.cz! prostoru pomyslné stely.[10][5]

Cellular Automata Game of Life – Generating Structures

UTB ve Zlín, FT, Institut ízení proces a aplikované informatiky 26

Gosper Glider Gun

Obr. 17. Dlo

Chování všech výše jmenovaných útvar je podmínno užitím klasického pravidla pro hru Život, tedy 23/3. V prbhu let se však objevily další desítky pravidel, které „hru Život“ pizpsobují k simulaci nkterých dj i pírodních úkaz.

Mezi ty nejzajímavjší patí: 57! navy.cs.vsb.cz! /3 pravidlo, v jehož dsledku dochází velmi rychle k vymírání populace

/2 pravidlo, díky kterému lze dosáhnou vysokého potu generací aniž by buky vymely. Poet bunk v generaci se po urité dob ustálí a v dalších generacích jich výrazn nepibývá, ale ani neubývá.

23/36 pravidlo vede k vtšímu potu zrozených bunk než v klasické he Život, ale jinak je chování obdobné.

4567/35678 pravidlo vedoucí k rychlému rozrstání populace

5/346 pravidlo vede na rychlý vznik oscilátor[5][7][10]

2.2.3 Logické funkce a hra Život

Hra Život je univerzální výpoetní nástroj obdobný Turingovu stroji a proto ji lze mimo simulací nkterých chemických i biologických jev využít také k výpotu napíklad logických funkcí.

Implementovat logické funkce v bunném automatu pedevším znamená njakým zpsobem reprezentovat promnné. Možností je napíklad reprezentovat každou promnnou pomocí útvaru zvaného dlo. Tento útvar v pravidelném cyklu neustále chrlí

Cellular Automata Game of Life

, , , , , , , ,

58! navy.cs.vsb.cz! Cellular Automata Game of Life

59! navy.cs.vsb.cz! Cellular Automata Logic Gates

• Glider gun produces string of gliders • In a stream, glider is as “1”s, gaps as “0”s • Carefully arrange streams to intersect and annihilate, to produce “gates” – NOT XOR gate example • http://rendell.server.org.uk/gol/pictures/notxor.htm • First step to building a computer in Life ...

60! navy.cs.vsb.cz! Cellular Automata Turing Machines in Life snapshot of execution schematic

http://rendell.server.org.uk/gol/tmdetails.htm P. Rendell. Turing Universality of the Game of Life. In Collision-Based Computing. Springer, 2002.

61! navy.cs.vsb.cz! Cellular Automata hierarchicalHierarchical CAs CAs

Hierarchical• hierarchical – – aa sequence sequence of of CAs, CAs, where where each each CA CAk+1 k is + controlled1 is controlled by a “hidden by a layer” CA“hidden k layer” CA k

(0) (0) (k +1) (k ) si,t+1 = φ()ηi,t ; si,t+1 = φ(ηi,t )

rule 10 rule 30 rule 42

– CA k+1 can “looklike” a simple CA, but not be described by one • Need to use an ever increasing neighbourhood as state increases –CA k + 1 can “look like” a simple CA, but not be described by one • need to use an ever increasing neighbourhood as state increases

Department of Computer Science NSC -- CAs -- 36

62! navy.cs.vsb.cz! Cellular Automata Dynamics

• Gospers_glider_gun – Gosper's Glider Gun creating "gliders" in the Conway's Game of Life

• Oscillator A cellular automaton based on hexagonal cells instead of squares (rule 34/2)

63! navy.cs.vsb.cz! Cellular Automata Simulating Physics

• CAs well-suited for modeling natural laws – grid of states: state of the “world” – single update rule: constant laws of physics – parallel update: uniform flow of time • CAs can be used as discrete analogues of PDEs of order at most n in space and 1 in time – higher order in time is possible for CA rules that depend on several previous time steps – spin glasses – wave equation – reaction-diffusion systems

64! navy.cs.vsb.cz! Cellular Automata Simulating Physics

• Amazing Game of Life Demo • Smooth Life • Epic conway's game of life • https://www.wolframscience.com/ • http://tones.wolfram.com/

65! navy.cs.vsb.cz! Want to Know More?

• https://www.wolframscience.com/ • http://tones.wolfram.com/ • Adamatzky, Andrew (Ed.), Automata, Universality, Computation, 2015, Springer Series: Emergence, Complexity and Computation, Vol. 12 • Rosin, Adamatzky, Sun (Eds.), Cellular Automata in Image Processing and Geometry, 2014, Springer Series: Emergence, Complexity and Computation, Vol. 10 • Andrew Ilachinski, Cellular Automata: A Discrete Universe, 2001, World Scientific

66! navy.cs.vsb.cz! Conclusions

The conclusion of the lesson are:

• Basics of CA’s were explained • Different behavior and patterns are produced by CA’s • There are rules of CA’s that has direct impact on CA’s dynamics • CA’s can be used as a pseudorandom number generator • CA’s are classified by Wolfram’s into classes 1 – 4 • CA’s are used in modeling and simulations

67! navy.cs.vsb.cz! THANK YOU FOR YOUR ATTENTION

[email protected] www.ivanzelinka.eu

68! navy.cs.vsb.cz! Copyright

This didactic material is meant for the personal use of the student only, and is copyrighted. Its reproduction, even for a partial utilization, is strictly forbidden in compliance with and in force of the law on Authors rights.

Copyright©NAVY.CS.VSB.CZ

69! navy.cs.vsb.cz!