Skip to content

AlexStratou/Game-of-life

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game-of-life

Conway's Game of Life in python.

1. Introduction

The Game of Life, is a zero-player game first conceived by John Horton Conway in 1970. The game is played in a 2d grid. Each gridpoint represents a live or dead cell. On each generation, the following rules are applied.

  1. Any live cell with fewer than two live neighbours dies.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies.
  4. Any dead cell with exactly three live neighbours becomes a live cell.

For more info, visit https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#References

2. Code

The game is implemented using an object oriented approach and the Python programming language. The code consists of 3 files.

  • life_source.py : The bulk of the code, contains the Life class which implements the game.
  • utils.py : Utilities like initial seed reshape function, periodic BC index managment, some initial seeds , etc.
  • run.py : The runfile of the program. The parameters are self explainatory.

Note that, as of now, the simulation grid is using periodic boundary conditions.

All classes, methods and functions have been thouroughly documented in the form of docstrings.

3. Examples

Below are some examplary animations created by the code for various initial seeds.

glider.mp4
lwss.mp4
die_hard.mp4
r_pentomino.mp4