|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.
You will implement the following methods in the GameBoard class:
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.
Start by importing the file assign3.zip into Eclipse: "File->Import->Existing Projects into Workspace", click "Select archive file", select "assign3.zip" 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 "LifeGUI.java" 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, "glider.life" 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 blinkers.life and animating it. A blinker is a 3-cell pattern that oscillates with period 2.
Make sure that when you load the file glider.life and animate it, the glider shape starts at the top left and moves towards the bottom right of the game board.
glidergun.life 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.
To submit the project, type the following commands in a terminal window (hitting return after each command):
cd cd eclipse-workspace submit102 assign3
You may submit as many times as you wish. The final submission prior to the deadline will be graded.