An interactive Conway's Game of Life, written in Python with NumPy and Pygame. Click to draw cells, change the speed and zoom while it runs, and watch each cell's color track how long it has survived.
Left-click any cell to bring it to life or kill it. Everything else lives in the side panel:
| Control | What it does |
|---|---|
| FPS slider | Sets the speed, from 1 to 60 generations per second |
| Increase / Decrease | Changes the cell size to zoom the grid in or out |
| Start / Pause | Runs or freezes the simulation |
| Step | Advances a single generation |
| Reset | Reseeds the grid with a random population |
Living cells are shaded by age. A cell born this generation is green. Once it has survived a few generations it turns blue, and after five it goes red. Dead cells are black, so long-lived structures stand out from the churn around them.
Requires Python 3.
pip install -r requirements.txt
python life.pyThe dependencies are NumPy, Pygame, and PGU, a small widget toolkit for Pygame.
The grid is a torus: it wraps at every edge, so a glider that slides off the right side reappears on the left. On each generation every cell counts its eight neighbors and applies Conway's rules: a live cell with two or three neighbors survives, a dead cell with exactly three neighbors comes to life, and everything else dies. A second grid tracks each cell's age, which is what drives the coloring.
