CS 117: Conway's Game of Life

Game of Life
Reed College Artificial Life Project

Overview

The Game of Life is a computer simulation of life, invented by John Conway and popularized via Martin Gardner's columns in Scientific American. A grid, like the one shown above, contains empty and filled cells. Each filled cell represents an "organism." Every turn, or "generation," of the game consists of applying Conway's three "genetic laws," which are:
  1. Survival: Every live cell with two or three live neighbors survives for the next generation.
  2. Death: Every live cell with four or more live neighbors dies (is removed) from overpopulation. Every counter with one live neighbor or none dies from loneliness.
  3. Birth: Every empty cell adjacent to exactly three neighbors is a birth cell. It becomes a live cell at the next move.
Your mission: Program this in Java.

Details

Create a Java program that does the following:
You should create a class called GameOfLife, with a static void method named main. This is the method that starts your program. Beyond this, you are free to structure your program as you wish, so long as it is reasonable and conforms with good style. Here are some ideas you may choose to follow:

Hints, Suggestions, Etc.

Extras

The following ideas are not required, but are things you can try if you want to push this further:
  1. Provide status information at the bottom of the canvas indicating how many cells are live, and how many generations have passed.
  2. Detect when nothing is changing, and stop the game.
  3. Detect when the game is stuck in a cycle, and prompt the user to stop if desired.
  4. Use InputBoxes and MessageBoxes (covered in your textbook) to communicate with the user instead of the Terminal Window.
  5. Make it into a 2 player game. A description of a 2 player version, called P2life, can be found here.
Note: The Game of Life is lots of fun, and quite popular. There are many versions of this game already available coded in Java on the web. Don't use them. See the syllabus for further info on plagiarism.