Skip to content
Conway's Game of Life, written in pure Python.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
life.py

README.md

Conway's Game of Life

Life implemented in pure Python3, visualized with curses and kept on a sparse matrix.

Getting Started

You will need to have Python3 installed on your system with curses support. There are no additional dependencies!

Clone the project and start a game with the following commands:

git clone https://github.com/madelyneriksen/game-of-life life
cd life
python3 life.py

Move around on the board with hjkl. You can close the game by pressing either q or C-c!

How It Works

Rather than representing the board with a matrix, numpy array, or Python list, we're using a dictionary. In mathematics, a representation of a sparse matrix with a dictionary is called a dictionary of keys, where all absent values are assumed to be zero.

Live cells are stored under their (x, y) coordinates:

{
    (10, 11): 1,
}

Curses then only renders cells that are on the visible screen.

License

All code in this project is MIT Licensed.

You can’t perform that action at this time.