Introduction
In 1970, the British mathematician John Conway created his "Game of
Life" -- a set of rules that mimics the chaotic yet patterned growth of
a colony of biological organisms. The "game" takes place on a
two-dimensional grid consisting of "living" and "dead" cells, and the
rules to step from generation to generation are simple:
- Overpopulation: If a living cell is surrounded by more
than three living cells, it dies.
- Stasis: If a living cell is surrounded by two or three
living cells, it survives.
- Underpopulation: If a living cell is surrounded by fewer
than two living cells, it dies.
- Reproduction: If a dead cell is surrounded by exactly
three cells, it becomes a live cell.
By enforcing these rules in sequential steps, beautiful and unexpected
patterns can appear.
The purpose of this project is to explore different starting
configurations and other variations on life.
Exercises
- Make a copy of your Game of Life notebook in Google Colab and
rename it for this project.
Generating Different Worlds
- Rename the
generateWorld
function to be
generateRandomWorld
. Modify your simulation
function to use this newly-named function and test that the behavior
looks the way you expect.
- Create at least two more world-generating functions based on
patterns found at Game
of Life Extensions or Conway's
Game of Life in Python. Your two worlds should come from
different categories (Still Life, Oscillating, Spaceship,
Perpetual). Things to think about:
- What parameters do your new functions need?
- Since you won't be generating random 1s and 0s, it might
make sense to create a world of all 0s and then change the cells
for the particular starting configuration to be 1.
- Make sure you return the world at the end of the functions.
- In a new Code cell you should test that each of your new
world-generating functions works properly. For each of your
functions, call the function with some size, say 10 or 20, and store
the world that gets returned in a new variable. Then
print that variable. Do this for each of your new functions. Make
any edits in your world-generating functions as needed.
- In your
simulation
function, comment out the line that
calls the generateRandomWorld
function and add a
statement to call one of your new world-generating functions. What
happens in the simulation?
- Run the main function with your other world-generating
function(s) with several different-sized worlds.
- Add a Text cell and describe what you see happening in the
simulations with these different worlds.
Modifying the Program Design
In order to make the program a little easier to use, some
reorganizing/redesigning will be helpful.
- Since the
generateRandomWorld
function is the
only one that uses a user-specified proportion of cells to be alive,
move that input statement from the main
function to the
generateRandomWorld
function. Then remove the parameter
corresponding to that value from the simulation
and
generateRandomWorld
functions, as well as any calls to
these functions. Make any other edits related to this as needed.
- Define a new function,
generateWorld
. This
function should take the world size as a parameter. It should ask
the user which type of starting world they would like to use. (Make
sure the input request informs the user of their options and
expected input values.) Based on that user-input, create the
corresponding world. At the end of this function, return the world
that was created.
- Modify your
simulation
function to call this new
generateWorld
function instead of a specific
world-generating function.
- Run the program multiple times, selecting different world
types, different sizes, and different numbers of generations.
Variations on Life
- Read about Variations
on Life. Choose one or more of these variations to
implement in your program. Include descriptive comments in your
code and use Text cells to explain what variation(s) you have chosen,
what you expect to see happen, and what results you obtained. This
is your chance to explore and be creative!
Submit
Check that you have completed the following for this project:
- Created at least two additional world-generating functions
- Built a more user-friendly input for selection of the world
- Implemented at least one variation on life
When you are satisfied your code is working properly, update the
description of the project in the
comments at the top of your file, make sure you have good
documentation throughout the project, make sure your name and the
date are at the top, and
then submit the notebook you created for this project via
Kit.