Conway’s Game of Life

2016-02-13, post № 104

games, mathematics, programming, Pygame, Python, #cells, #cell, #cell simulation, #cellular, #cellular automation, #cellular game, #cellular simulation, #John Conway, #simulation

This program is a simulation of the famous cellular automaton created by John Conway. The so-called ‘game’ is rather a simulated evolution of cells in a two-dimensional world. Each cell can either be dead (black) or alive (white) and always has eight neighbours surrounding them. In each cycle of the simulation their state will be changed based on two simple rules, which are listed below.
Despite the rule’s simplicity, the outcomes are often very interesting and complex.
For more details on the game of life, check this Wikipedia entry.

The Rules

  • A live cell can only survive with exactly 𝟤 or 𝟥 neighbours, or else it dies.
  • A dead cell with exactly 𝟥 neighbours comes to life.


  • Left click turns cell at current mouse position alive,
  • Right click turns cell at current mouse position dead,
  • ‘r’ turns every cell dead,
  • ‘q’ cycles once,
  • ‘w’ cycles continuously.
Source code: conways-game-of-life.py
Jonathan Frech's blog; built 2024/05/27 06:43:58 CEST