CMPU 102 - Assignment 3 Due: by 11:59 PM on Thursday, February 16th

In this assignment, you will implement Conway's Game of Life.  Life is a simulation of simple one-celled organisms.

Cells either live or die according to the Rules of Life:

A simple GUI is provided so that you can visualize the progress of the successive generations of organisms.

Your task is to implement the class GameBoard which represents one generation of cells.  The board is a two-dimensional grid of cells, where each cell contains an integer value.  The value of a cell is either 0, meaning that the cell is dead, or some positive integer representing the number of generations that the cell has been alive.

Methods to implement

You will implement the following methods in the GameBoard class:

Before You Do Anything Else

In this course we will be using new features that were introduced in the most recent version of Java.  So, we need to tell Eclipse that we want to use these new features.

In Eclipse, choose "Window->Preferences...->Java->Compiler".  In the dialog, set "Compiler compliance level" to "5.0".  Click "Ok" and then answer "Yes" when prompted whether or not you want to do a full rebuild.

After this configuration change, you will be able to use the latest Java features in all of your projects.

Getting started

Start by importing the file into Eclipse: "File->Import->Existing Projects into Workspace", click "Select archive file", select "" from the file selection dialog, and then click the "Finish" button.

The LifeGUI class has a main method that will start the GUI interface.  To execute LifeGUI, right-click "" in the Package Explorer, then choose "Run As->Java Application".

The Random button creates a new random game board.  The One Step button applies the Rules of Life to the current game board; therefore, it is a good way to test your implementation of the GameBoard class.  Once you have GameBoard working, you can use the Animate button to play a sequence of generations, 3 generations per second.  The Load button will use your implementation of the loadFromFile method to load a new game board.  Some sample files are provided in the "handouts" folder in your project: for example, "" initializes the board to display a single glider pattern, which evolves in an interesting way.  (Note that when you run the GUI, the file chooser will start in your home directory.  To get to the sample files, look in the "eclipse-workspace/life/handouts" directory.)


Try loading and animating it.  A blinker is a 3-cell pattern that oscillates with period 2.

Make sure that when you load the file and animate it, the glider shape starts at the top left and moves towards the bottom right of the game board. produces a stream of gliders.

When you are computing the GameBoard representing the next generation, remember that the value of the cells in the new game board records the number of generations that the cell has been alive.  The GUI displays the number of generations a cell has been alive using different colors: red cells are new, yellow and green cells have lived a few generations, and blue and purple cells are oldest.

Submitting the project

To submit the project, type the following commands in a terminal window (hitting return after each command):

cd eclipse-workspace
submit102 assign3

You may submit as many times as you wish.  The final submission prior to the deadline will be graded.