wlof / gameoflife

A simple Python implementation of Conway's Game of Life using the curses library.
MIT License
3 stars 0 forks source link

Game of Life

This is a simple Python module implementing Conway's Game of Life, with a curses-based UI.

The game runs on a torus (i.e. the edges of the screen are connected). Default size is 100x100.

Game of Life

Installation

From GitHub:

$ git clone https://github.com/wlof/gameoflife
$ cd gameoflife
$ sudo python setup.py install

If you're running Windows, you will need to install the unofficial curses library. Download it from http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses.

If you want to use the slightly faster NumPy/SciPy implementations, you will of course have to install these libraries: http://www.scipy.org/scipylib/download.html

Usage

After installation, run the game using:

gameoflife

There a few arguments you can use:

usage: gameoflife [--impl {normal,light,numpy,numpy-light}] [--width WIDTH]
                  [--height HEIGHT] [--prob PROB] [--color {auto,yes,no}]
                  [--version] [--help]

Conway's Game of Life

optional arguments:
  --impl {normal,light,numpy,numpy-light}, -i {normal,light,numpy,numpy-light}
                        game implementation
  --width WIDTH, -w WIDTH
                        grid width
  --height HEIGHT, -h HEIGHT
                        grid height
  --prob PROB, -p PROB  initial population probability
  --color {auto,yes,no}, -c {auto,yes,no}
                        use colors
  --version             show program's version number and exit
  --help                show this help message and exit

Suggestions and bug reports are greatly appreciated:
https://github.com/wlof/gameoflife/issues

Implementations

There are four different implementations that you can use (with the --impl command line argument):

Legend

The cells are represented as follows:

Additionally, the color of each cell indicates its age:

Manual

During the game, you may use the following keys: