CS 117: Artificial Life

Life

Overview

Artifical life is the area of study that is characterized by simulating aspects of living beings with a computer. Perhaps the most well-known example of artifical life, referred to as "ALife" by some, is the "Game of Life" by John Conway. 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 organism 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, which contains your main method. 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. 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.