Conway’s Game of Life

Indices and tables

Background

Not actually a game, Conway’s Game of Life is a cycle-based simulation of the evolution of cells based on a initial condition (the initial cell population) and some simple rules that determine whether each cell lives or dies on each cycle.

Wikipedia provides a a good overview along with the cycle-to-cycle rules and some ideas for initial populations.

Exercise

Implement Conway’s Game of Life using Python.

The initial population is up to you.

The screen should NOT scroll, but, rather fully refresh on each cycle.

Hints

  • The terminal has crazy functionality most people are not aware of. It is exposed via escape codes, which you can read about here. Keep in mind, Jupyter is NOT a terminal, and you won’t be able to get it to NOT print a new line for each cycle of the progress bar. Use PyCharm or the interpreter instead.
  • Checkout the time module for methods to pause execution temporarily.
  • If you are not already familiar with using PyCharm to run and debug source code, this is a great project to learn how to do it. There WILL be many situations where you will want to interrogate the value of your internal objects and PyCharm is much more powerful at this than literring your code with print() statements.

Solution

When you are ready to see one possible solution, try this file