madelyneriksen / game-of-life

Conway's Game of Life, written in pure Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Conway's Game of Life, written in pure Python.


Languages

Language:Python 100.0%