Conway's Game of Life

In memory of the recently deceased John Conway, I have made this small implementation of his most iconic creation: Game of Life

For those who haven't already heard of it, Game of Life is a cellular automaton. Cellular automata are essentially girds of cells, each having one of some possible states (e.g. on-off, alive-dead etc). Also, a set of rules accompany the grid, which, given a particular state of the grid, determine a new state for each cell of the grid, producing a new generation of the grid.

The rules of a cellular automaton are the same for each cell, and apply simultaneously to all cells of the grid, although they consider one cell at a time. These rules are usually a function of the surrounding cells' states. For example, lets see what the rules of Game of Life are:

In Game of Life, cells have two possible states: alive and dead. The rules are a function of the number of alive cells adjacent to each cell (horizontally, vertically and diagonally), called neighbours for short, and go as following:

1. Any live cell with fewer than two live neighbours becomes dead
2. Any live cell with two or three live neighbours stays alive
3. Any live cell with more than three live neighbours becomes dead
4. Any dead cell with exactly three alive neighbours becomes an alive cell

Or, in a table form:

(apparently markdown tables are not supported)

Although it might appear from the above ruleset that all cells will eventually die, this is not always the case. Many initial states will stay alive for long periods of time, or even forever. See more here

Note: there are some patterns of cells that stay still or oscillate. So, if you run the game and, at some point, nothing moves, it's probably because of this, and not because the program stuck.

Even if you don't quite understand how it works, looking at little things blink is a great way to kill some time during the lockdown. Hope you enjoy it!

You are viewing a single comment. View All
Warhawk947 (444)