Skip to content

JackB296/life-sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of Life

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.

A grid of cells evolving, colored green when just born, blue while young, and red once they have survived several generations

Controls

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

Cell colors

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.

Running it

Requires Python 3.

pip install -r requirements.txt
python life.py

The dependencies are NumPy, Pygame, and PGU, a small widget toolkit for Pygame.

How it works

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.

About

Interactive Conway's Game of Life with live controls and age-based cell coloring (Python, NumPy, Pygame)

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages