Life Game
An implementation of Conway's Game of Life in JS
Note: Due to rendering limitations, the simulation may not behave as expected on screens with a size smaller than 800 x 600. To optimal quality, we recommend to visit this webpage on a desktop computer.
Introduction
The Game of Life, also known simply as Life, is a cellular automaton devised by John Horton Conway in 1970.
It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. A 'player' interacts with the Game of Life by creating an initial configuration and observing how it evolves by itself.
Rules
The universe of the Game of Life is a two-dimensional grid of square cells, each of which is in one of two possible states: alive or dead. Every cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- Any live cell with fewer than two live neighbors dies (under-population).
- Any live cell with two or three live neighbors lives on the next generation.
- Any live cell with more than three live neighbors dies (over-population).
- Any dead cell with exactly three live neighbors becomes a live cell (reproduction).
The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is called a tick. The rules continue to be applied repeatedly to create further generations.
Cellular automata
A cellular automaton is a discrete model studied in computability theory, mathematics, physics, complexity science, theoretical biology and microstructure modeling.
A cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off (or dead or alive, as in the Game of Life). The grid can be in any finite number of dimensions. For each cell, a set of cells called its neighborhood is defined relative to the specified cell.
An initial state (time t = 0) is selected by assigning a state for each cell. A new generation is created by advancing t by 1, according to some fixed rule (generally, a mathematical function) that determines the new state of each cell in terms of the current state of the cell and the states of the cells in its neighborhood.
Typically, the rule for updating the state of cells is the same for each cell and does not change over time, and is applied to the whole grid simultaneously.
Sources
All of the simulation's code is written completely on JavaScript. You can download and examine the source code here.
The code requires JQuery 2.1.4 or higher to work.