Skip to content

poco-loco-athul/Game-of-Life

Repository files navigation

Introduction

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: How It Works

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.

Usage

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).

Background

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.

Requirements

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

Tests

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 for gameoflife. It has 100% coverage.
  • test_RLEsupport.py contains tests for RLEsupport. It has 100% coverage.

About

A simple python implementation of the Conway's game of life, using Test-Driven Development approach.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages