Cellular Automata

Finite Cellular Automata

Even without turtles, ponds can exhibit interesting patterns of behavior. In fact, we can view a turtle-free pond as a finite version of a powerful computational model called a cellular automaton (CA).

CAs were introduced in the late 1940s by two mathematicians: Stanislaw Ulam and John Von Neumann. They were motivated by the question: could machines reproduce? In other words, could we build a machine that builds a copy of itself when switched on?

A CA is an infinite grid of cells. Each cell, C, is a simple "machine" that might represent the behavior of a region, household, individual, etc. At any time t, C is in one of N states. States can be anything: temperature, wealth, political affiliation. At time t + 1, C may transition into another state. The new state is determined by the states of C and its neighbors at time t.

While the behavior of each individual cell is necessarily simple, we might wonder if the behavior of the CA taken as a whole might be complex and interesting. It turns out that the answer is yes. In fact, it is theoretically possible to compile any program into a CA. This should not be too surprising considering that the human brain can be viewed as a CA in which neurons play the role of cells.

Conway's Game of Life

The Game of Life was invented by British mathematician John Conway and was popularized in Martin Gardner's Mathematical Games column in the October 1970 issue of Scientific American.

The Game of Life is not actually a game. It is a powerful family of CAs. Each cell is in one of two states: 0 = dead or 1 = alive. The ambiance of a cell is simply the sum of the states of its eight neighbors. This corresponds to the number of living neighbors and therefore is a number between 0 and 8:

0 <= ambience <= 8

T01 and T10 are user-defined subsets of the set of all possible values for ambience:

{0 1 2 3 4 5 6 7 8}

During the update phase a cell is reborn (transitions from state 0 to state 1) if its ambience is in the set T01 and dies (transitions from state 1 to 0) if its ambience is in the set T10. Otherwise the state of the cell doesn't change. Users can experiment with different values for T01 and T10. They don't need to be disjoint, and one or both can be empty. In Conway's original version:

T01 = {3}
T10 = {0 1 4 5 6 7 8}

In other words, a cell dies if it's too lonely (0 or 1 living neighbors) or too crowded (4 or more living neighbors), and a cell is reborn if it has exactly three living neighbors.

Implementing Life

We can implement Life by customizing the Eco-0 framework.

Obviously we don't need to implement any turtle procedures. CAs are patch-only models.

The only collections NetLogo supports are lists and agent sets. Therefore, we will use lists to represent the transition sets. We define these lists as global variables. Patch attributes include state and ambience:

globals [T01 T10]
patches-own [ambience state]

Recall that globals are initialized in the Eco-0 framework by the init-globals procedure. We use list literals to initialize or transition lists:

to init-globals
  set T01 [3]
  set T10 [0 1 4 5 6 7 8]
end

Each patch initializes its attributes by executing init-patch. In this version we set the state and ambience to random values:

to init-patch
  set ambience random 8
  set-state random 2
end

The set-state procedure sets the state and color of a cell:

to set-state [new-state]
  set state new-state
  ifelse state = 0
  [
    set pcolor black
  ]
  [
    set pcolor white
  ]
end

Unfortunately, we need to make some modifications to the Eco-0 framework for CAs. In particular, we need to break the model-update loop into two phases, an observational phase where each patch sets the value of its ambience attribute, and an update phase where each patch updates its state:

to update-model
  update-globals
  ask patches [observe]
  ask patches [update-patch]
 ; ask turtles [update-turtle]
   tick
end

This needs to be done because at time t + 1 each patch must updates its state based on the states of its neighbors at time t.

We define a new observation procedure:

to observe
  set ambience count neighbors with [state = 1]
end

The update-patch procedure uses the member? reporter to determine if a state transition is necessary:

to update-patch
  ifelse state = 0
  [
    if member? ambience T01
    [
      set-state 1
    ]
  ]
  [
    if member? ambience T10
    [
      set-state 0
    ]
  ]
end

Improving Life (version 2.0)

To facilitate experimentation we provide users with two ways to initialize cells: randomly or individually.

Here's a screen shot of the interface just after random initialization:

When the randomize switch is off, then all cell states are initialized to 0.

The toggle-cells button repeatedly calls the toggle-cells procedure:

The procedure checks to see if the mouse button is down. If so, it sets the state of the patch under the mouse:

to toggle-cells
  if mouse-down?
  [
    wait 0.5 ; slow things down a bit
    ask patch mouse-xcor mouse-ycor [set-state ((state + 1) mod 2)]
  ]
end

Here's the new init-patch procedure:

to init-patch
  ifelse randomize
  [
    set-state random 2
  ]
  [
    set-state 0
  ]
  set ambience random 8
end

The complete model is here:

life.nlogo

Lab

Experiment with the model. Can you find initial configurations that don't eventually die?

Applications and Exercises

Voting Patterns

Schelling's Segregation Model

The Conway Universe

Brian's Brain

Improving Life

Hammond's Corruption Model

Epstein's Civil Disobedience Model

Lovelock's Daisy World

Wolfram's New Kind of Science

Labs

Lab 1

Axelrod's Cultural Dissemination Model

Lab 2

Complete the implementation of Shelling's Segregation Model.

Lab 3

Implement and test Brian's Brain.

Lab 4

Implement and test Hammond's Corruption Model.