CSCI427 Wk01 Lab Part3
CSCI427 Wk01 Lab Part3
D E PA R T M E N T O F C O M P U T E R S C I E N C E A N D I N F O R M AT I O N S Y S T E M S
The goal of this assignment is to set up a machine learning environment on your personal
computer and to gain some familiarity using it.
WHAT TO SUBMIT
• The installer checks which packages need to be installed or updated and asks you to Apply
those changes.
We can now launch Jupyter Lab by clicking the Launch button on the Home tab.
Jupyter Lab will launch into your default web browser.
Part 2: Learning to Use Jupyter Lab
Complete the notebook in the archive.
Part 3: The Game of Life
BACKGROUND
The Game of Life ("Conway's Life" or just "Life") is a cellular automation that simulates a self-
replicating system and was devised by John Conway, a British mathematician. It first appeared
in the October 1970 issue of Scientific American. Life grew out of early research into robots
creating robots and self-replicating robots.
The universe Life simulates is a two-dimensional grid of square cells, each of which has one of
two possible states, live or dead. Every cell interacts with its eight neighbors, which are the cells
that are horizontally, vertically, or diagonally adjacent. At each step in time, the following
operations occur:
• Any live cell with less than two live neighbors dies from loneliness.
• Any live cell with two or three live neighbors lives on to the next generation.
• Any live cell with more than three live neighbors dies from overpopulation.
• Any dead cell with exactly three live neighbors becomes a live cell -- a birth.
Another way to state these rules is this:
Stable or Still Life -- sets of cells that all have two or three neighbors and so remain
alive every generation.
Oscillators -- shapes that repeat over a period of generations. The simplest oscillator is
a set of three cells in a line that alternates between horizontal and vertical each
generation.
Spaceships -- shapes that oscillate, but shift position each time they return to their
original shape so they appear to move across the grid. The simplest spaceship is the
glider, which we will create in this lab. We will also create a Gosper Glider Gun that
sends out gliders as it oscillates.
Sadly, it is also possible for all cells to eventually die and the species to go extinct.
(Portions of this background are from Wikipedia.)
STEP A: SET-UP
generates this:
Game of Life
by Timothy Henry
The first code cell should always import necessary libraries. The aliases you see here are
common aliases you’ll see in many code examples and throughout this course.
Let’s initialize some constants and variables that help determine how the animation will run. We
write them in this notebook cell so that they are easier to find and change if we want to change
the simulation.
• Theses constants are used so it is easier to read how the grid is initialized:
# Game Constants
LIVE = 1
DEAD = 0
STATUS = [LIVE, DEAD]
• We are going to create three different starting configurations. Feel free to create more if you
like! The variable gameSeed determines which configuration is used for this run.
• For our random initial configuration we set the probability that a cell is live or dead here.
# for random cell initialization, probability of live or dead cells
probabilityLive = 0.15
probabilityDead = 1.0 - probabilityLive
Each of the different seed shapes has its own function. A good practice it to place each of the
functions in its own notebook cell.
• This function creates a small array with the initial glider spaceship shape. If this is the
selected shape, the small array is use to overwrite the main grid’s cells starting at (i, j).