Conway's Game of Life is a cellular automaton devised by the mathematician John Horton Conway. It's a zero-player game that simulates the life cycle of cells on a two-dimensional grid based on a set of simple rules. The grid consists of cells that can be in one of two states: alive or dead. The state of the cells evolves in discrete steps according to the following rules:
Rule | Description |
---|---|
Underpopulation |
Any live cell with fewer than two live neighbors dies , as if by underpopulation. |
Survival |
Any live cell with two or three live neighbors lives on to the next generation. |
Overpopulation |
Any live cell with more than three live neighbors dies , as if by overpopulation. |
Reproduction |
Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction. |
- Neighbors: Each cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent.
- Grid Evolution: The state of the grid evolves simultaneously; all cells are updated at the same time based on the rules.
- Initial Configuration: The initial state of the grid is provided as the starting point, and subsequent states are generated by applying the rules iteratively.
Consider a 3x3 grid with the following initial state:
0 1 0
0 1 0
0 1 0
Here, 1
represents a live cell and 0
represents a dead cell.
Applying the rules:
- The live cell at (1, 1) has two live neighbors (itself and the cell directly below it), so it remains alive.
- The live cell at (2, 1) has only one live neighbor (the cell directly above it), so it dies due to underpopulation.
- The live cell at (3, 1) has two live neighbors (itself and the cell directly above it), so it remains alive.
- The dead cells at (2, 0) and (2, 2) each have three live neighbors, so they become alive due to reproduction.
Next generation state:
0 0 0
1 1 1
0 0 0
In this way, the game continues to evolve according to the rules of underpopulation, survival, overpopulation, and reproduction.