esolang

Game of Life

Not a language but a universe with two rules. The program is the starting pattern, and it can be a computer, or a machine that copies itself.

John Horton Conway, 1970 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 1 known program · Test method

Run it

Gosper’s glider gun (1970), the first pattern found to grow forever. A glider leaves every 30 generations.

The idea

John Horton Conway designed the Game of Life in 1970, looking for the simplest rule that would make patterns that are hard to predict: not dying out quickly, not exploding. Martin Gardner published it in his "Mathematical Games" column in Scientific American in October 1970, and a generation of programmers spent their computer time on it.

Read the story

It is a cellular automaton: a grid of cells, each alive or dead, all updated at once by the same local rule. There are no instructions. What plays the role of the program is the initial pattern; running it means applying the rule, generation after generation.

Out of that come moving things (gliders), guns that fire them (Bill Gosper's group found the first in November 1970, winning a prize Conway had offered), and eventually logic gates made of glider streams. Life is Turing complete: with enough room you can build any computer in it.

The machine

An infinite square grid. Each cell looks at its eight neighbours.

The cell isLive neighboursNext generation
Deadexactly 3Born
Alive2 or 3Survives
Anything elseDead

This is written B3/S23 (born with 3, survives with 2 or 3). Other rules in the same family have their own names and worlds.

Example

The glider: five cells that rebuild themselves one cell diagonally away every four generations.

The glider: five cells that rebuild themselves one cell diagonally away every four generations.

gen 0      gen 1      gen 2      gen 3      gen 4
.#.....    .......    .......    .......    .......
..#....    #.#....    ..#....    .#.....    ..#....
###....    .##....    #.#....    ..##...    ...#...
.......    .#.....    .##....    .##....    .###...

Generation 4 is generation 0 moved one cell right and one down. (The script prints the generations one under the other; they are side by side below.) The grid wraps at the edges, so a glider in the script flies forever.

Self-copying in Life is real but huge. Gemini (Andrew J. Wade, 2010) is a spaceship that builds a copy of itself from an instruction tape and deletes the original. In 2013 Dave Greene built the first pattern that copies itself completely, tape included.

Patterns it teaches

  • Cellular automata: the classic. Local rule, global behaviour.
  • Turing completeness: gliders as signals, collisions as gates. Programs are drawings.
  • Self-replication: von Neumann's question (can a machine build itself?) answered inside a two-state rule, with a tape and a constructor.
  • Artificial life: the name says it, though nothing in Life evolves unless you add noise.

Try this

  1. Draw a blinker (### in a row) in a file and run it with shib run game-of-life file.txt --input 4. What is its period?
  2. Put two gliders on a collision course. Find a placement where both are destroyed.
  3. Hard: find the smallest pattern that is still changing after 100 generations.

Further

  • conwaylife.com/wiki: every known pattern.
  • Martin Gardner, "Mathematical Games: The fantastic combinations of John Conway's new solitaire game 'life'", Scientific American, October 1970.
  • Golly, a fast simulator that can run Gemini.

Cellular automata

Non-textual

Write your own in Run Convert a program from Game of Life

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: game-of-life.

Command line

shib run game-of-life -e '.#.....
..#....
###....
.......
.......
.......
.......' --input '1'
shib manual game-of-life

Source

Module
langs/museum/ports.js
Interpreter
langs/museum/game-of-life.js, langs/common.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org