Conway's Game of Life is my second project while learning python. It's a simple implementation. I recommend you to try this eventually if you are also a beginner to python.
Conway's Game of Life is more of a mathematical simulation than a game. The "game" is actually a zero-player game, meaning that its evolution is determined by its initial state, needing no input from human players. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.
Requires python3.x Does not requires numpy
or other
packages to run the simulation.
To run blinker configuration:
$ python blinker.py
ConwayLife.com have a very good collection of
patterns. The
RLE(Run Length Encoded) file
format is commonly used for storing large patterns. RLE can be decode
by functions in RLEsupport.py
. Examples are given in
other_configuration.py
. In the same file the patterns are then coded
to animated in terminal using curses
module.
$ python other_configuration.py
End program using a keyboard interrupt (ctrl-c).
Initial configuration of the game of life is given through a
matrix. Each element in this matrix is defined as a cell. At first,
the program finds the number of neighboring alive cells for each
cell. Then applies Conway's rules and produces the next
generation. Each generation is displayed as a string. This process
continues in a loop. Read spec.txt
to see the notes on the project.
Check requirements.txt
for other dependencies
- install them with
pip install -r requirements.txt
- to add more dependencies, use pip and:
pip freeze > requirements.txt
This project is developed through Test Driven Development. Once required dependencies are there, tests can run. To test:
pytest test_gameoflife
To check coverage of these tests:
pytest --cov=gameoflfe
test_gameoflife.py
contains tests forgameoflife
. It has 100% coverage.test_RLEsupport.py
contains tests forRLEsupport
. It has 100% coverage.