# Game of life

## Overview

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent.&#x20;

At each step in time, a cell will die, populate or remain unchanged according to a set of rules about its neighbouring cells.

{% hint style="info" %}
More information can be found on Wikipedia: [https://en.wikipedia.org/wiki/Conway%27s\_Game\_of\_Life](https://en.wikipedia.org/wiki/Conway's_Game_of_Life)
{% endhint %}

## Objectives

### Basis

* The 'grid' is infinite and is as big or as small as the live cells it contains.
* There are two states for a cell:&#x20;
  * alive
  * dead
* There are three types of transition for a cell:
  * a dead cell is born (becomes a live cell)
  * a live cell dies (becomes a dead cell)
  * a live cell continues to the next generation (remains a live cell)
* The initial pattern constitutes the seed of the system, see the [examples section](#examples) for some known seeds.
* The rules continue to be applied repeatedly to create further generations ad infinitum.

### Game rules

The first generation is created by applying the rules below *simultaneously* to every cell in the seed—births and deaths occur simultaneously - and the discrete moment at which this happens is called a tick (in other words, each generation is a pure function of the preceding one).

At each tick, the following transitions occur:

* Any live cell with fewer than two live neighbours dies, as if caused by under-population.
* Any live cell with two or three live neighbours should live on to the next generation.
* Any live cell with more than three live neighbours dies, as if by over-population.
* Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.&#x20;

## Examples

The simplest possible seed is one with no live cells. It will stable from the very first tick as no new cells can be born.

The second simplest seeds is one live cell. The cell will die from underpopulation on the first tick and will then be stable from the second tick as no new cells can be born.

{% hint style="info" %}
Any seed with no triominos (three adjacent cells), regardless of the total number of live cells, cannot live past the first tick as no new cells can be born.
{% endhint %}

### Basic multi-generation seeds

#### Triominos

Made up of three adjacent cells

<div align="left"><img src="https://4149111635-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LC4jNukcZ-2vlqVVdIC%2F-LeutQygV583qzurA3Kg%2F-Lev1OTjNUXZuQpV1UjY%2Fimage.png?alt=media&#x26;token=452d585a-0c25-4b2d-88f6-fd904d8814a6" alt="Credit: http://pi.math.cornell.edu/~lipa/mec/lesson6.html"></div>

#### Tetrominos

Made up of four adjacent cells

<div align="left"><img src="https://4149111635-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LC4jNukcZ-2vlqVVdIC%2F-LeutQygV583qzurA3Kg%2F-Lev1XrNF0sEPXs7y1CN%2Fimage.png?alt=media&#x26;token=b32be211-e8d3-460c-84f8-165f5b0eb518" alt="Credit: http://pi.math.cornell.edu/~lipa/mec/lesson6.html"></div>

#### The Gosper glider gun

This advanced pattern will live through infinite generations.

<div align="left"><img src="https://4149111635-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LC4jNukcZ-2vlqVVdIC%2F-LeutQygV583qzurA3Kg%2F-Lev4TGRNPeovv79-w4M%2Fimage.png?alt=media&#x26;token=e89e9fe3-77eb-46c2-a1d2-b5bc0e6a62ac" alt="Credit: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life"></div>

The Gosper glider gun in action:

<div align="left"><img src="https://4149111635-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LC4jNukcZ-2vlqVVdIC%2F-Lev5GtXzVbuIuNiEiOK%2F-Lev5bLDm4bbJ_v0vMdt%2FGospers_glider_gun.gif?alt=media&#x26;token=7368b646-cb7f-4db1-9fd1-c08eab2d864b" alt="Credit: Kieff - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=101736"></div>
