# Conway's Life

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## Conway's Game of Life

A [NetLogo] model by Rik Blok.

http://www.zoology.ubc.ca/~rikblok/wiki/doku.php?id=science:conway*s*game*of*life:start

This [NetLogo] model implements Conway's Game of Life a cellular automaton John Horton Conway designed to be difficult to anticipate the dynamics of starting patterns. This implementation incorporates some ideas I focused on in my research: finite-size effects [[Blok97]] and asynchronous updating [[Blok99]].

## How it works

Each site on the square 2-dimensional lattice can be in one of two states (*alive* or *dead*). All sites are updated in parallel according to the following rules:

- Loneliness: An
*alive*site with less than two of its 8 nearest neighbours also*alive*becomes*dead*; - Overcrowding: An
*alive*site with more than three*alive*neighbours becomes*dead*; and - Birth: A
*dead*site with exactly three*alive*neighbours becomes*alive*.

Otherwise, sites remain in the same state.

In this implementation, *alive* sites are shown in bright yellow. *Dead* sites fade to black.

## How to use it

Choose **world-size** and **initial-density** of *alive* sites and press **setup** to create a random starting configuration. You may also press **draw** to draw your own starting configuration with the mouse.

Press **go** to repeatedly apply the rules and watch the configuration evolve. Adjust the **speed slider** at the top as desired. You may also **draw** while the simulation is going.

You may adjust the **synchronicity** of the simulation -- the fraction of sites that are updated on each iteration. When **synchronicity**=100% we have Conway's original Game of Life. As **synchronicity** is reduced some sites are skipped in each step, so the dynamics start to deviate from Conway's. As **synchronicity** approaches 0% most sites are not updated in any one iteration, and the simulation approaches asynchrony -- almost the same as one site updating at a time. Notice how the patterns differ as **synchronicity** varies.

To perturb a configuration -- by toggling one site -- press **bump**. You may want to do this once the dynamics have settled to a stable (or simply repeating) pattern. Some bumps will have little effect but occasionally they will cascade through the whole space, changing the entire system. It is difficult to predict the size of the cascade.

## Things to notice

Since there are a fixed, finite number *N* of sites there are only a finite number of possible configurations (2^*N*) and the configuration must necessarily repeat as it evolves. In principle the period between repeating configurations could be anything up to 2^*N* but in practice it is much shorter: typically 1 or 2. A notable exception can occur when **synchronicity**=100% and a glider is present -- rarely a glider may travel around the entire length of the space and return to its original position.

## Things to try

### Draw

Try drawing your own starting configuration. Set the **initial-density**=0% and press **setup** to set all sites to *dead*. Press the **draw** button to activate drawing mode, then use the mouse to draw a shape, such as the R-pentomino.

### Boundary conditions

This implementation defaults to *periodic* boundary conditions: the left side can be thought of as wrapping around to touch the right and the top touches the bottom. In the native version of NetLogo (not the applet) you can switch to *cold* boundaries where any sites outside of the visible area are assumed to be *dead* -- press **Settings...** at the top-right of the interface and toggle the **World wraps...** checkboxes. Notice that periodic boundaries reduce edge effects [[Blok97]].

## References

[[Blok97]] Hendrik J. Blok and Birger Bergersen. Effect of boundary conditions on scaling in the "game of Life". *Phys. Rev. E*, 55:6249-52. doi:10.1103/PhysRevE.55.6249. 1997.

[[Blok99]] Hendrik J. Blok and Birger Bergersen. Synchronous versus asynchronous updating in the "game of life". *Phys. Rev. E*, 59:3876-9. doi:10.1103/PhysRevE.59.3876. 1999.

[[NetLogo]] Wilensky, U. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL. 1999.

## Comments and Questions

globals [ last-mouse-x last-mouse-y count-alive count-patches time-elapsed ] patches-own [ nbrs new-nbrs ] to startup setup end to setup if (world-size = " 64x64 ") [ resize-world 0 63 0 63 ] if (world-size = "128x128") [ resize-world 0 127 0 127 ] if (world-size = "256x256") [ resize-world 0 255 0 255 ] if (world-size = "512x512") [ resize-world 0 511 0 511 ] set-patch-size (512 / world-width) clear-all ask patches [ if (random 100 < initial-density) [set pcolor yellow] ] set count-alive count patches with [pcolor = yellow] set count-patches count patches ask patches [ ; set new-nbrs nbr-count set new-nbrs count neighbors with [pcolor = yellow] ] reset-ticks end to go reset-timer ask patches [set nbrs new-nbrs] if-else (synchronicity = 100) [ ; shortcut for perfect synchrony ask patches with [pcolor != black or nbrs > 1] [ update ] ][ ; might be faster to select binomial subset of patches for small synchronicity ask patches with [pcolor != black or nbrs > 1] [ if random 100 < synchronicity [ update ] ] ] tick-advance synchronicity / 100 plotxy ticks count-alive * 100 / count-patches set time-elapsed time-elapsed + timer end to update ifelse (nbrs = 3) or ((nbrs = 2) and (pcolor = yellow)) [ turn-on ][ turn-off ] end to draw if mouse-down? [ ask patch mouse-xcor mouse-ycor [ if not ((pxcor = last-mouse-x) and (pycor = last-mouse-y)) [ toggle ] set last-mouse-x pxcor set last-mouse-y pycor display ] ] end to turn-on if (pcolor != yellow) [ set count-alive count-alive + 1 ask neighbors [ set new-nbrs new-nbrs + 1 ] ] set pcolor yellow end to turn-off if (pcolor = yellow) [ set count-alive count-alive - 1 ask neighbors [ set new-nbrs new-nbrs - 1 ] ] ; note: color 40=black, 45=yellow set pcolor ifelse-value (fade and pcolor > 40) [pcolor - 1] [black] end to toggle ifelse (pcolor = yellow) [ turn-off ][ turn-on ] end to bump ask one-of patches with [new-nbrs > 0] [ toggle ] end

There is only one version of this model, created over 5 years ago by Rik Blok.

This model does not have any ancestors.

This model does not have any descendants.