CPE 101:
Fundamentals of Computer Science 1


Spring 2003
(Sections 02 & 03 only)
Program # 6, Option #1 
Due by 9 p.m., Wednesday of Week # 10.
You may work with a partner on this assignment. If you worked on Assignment #5 with a partner, however, you may not submit a joint assignment with the same person for this one. (Find another Program 5 team, perhaps, and swap...) If you do work with a partner, make sure that each person's role is clearly delineated in the program documentation.



Task Navigation Links:
| The Game of Life | Some Notes |
| Submitting Your Work |

The Game of Life

The game of "life" was invented by the mathematician John Conway in 1970. It consists of a grid of cells which are either alive or dead and a set of rules for determining which cells will be alive or dead in the next generation. It is an example of what computer scientists refer to as Cellular Automata, that is, systems of cells in a grid where rules are applied that govern the activities of cells and their neighbors.

For a very nice treatment of the game complete with examples, see the web page at:

http://www.math.com/students/wonders/life/life.html

For this assignment, you will take the ScoreBoard classes distributed Lab 9 and create a Java applet which runs Life in a 50 by 50 grid. Like we did with the gradual development of your Slot Machine game, this doesn't involve many new concepts, but it does take what you should already know and push it a little further.

Your game should:

  1. Create an initial board and and choose cells randomly to be alive or dead. (Use Math.random() for this.) 25% live cells seems to produce pretty good runs.

  2. Update the board according to the rules. For each generation: These counts of neighbors are done before any updates and all cells are then updated at once. For purposes of counting neighbors, the grid border is considered dead.

  3. The game continues to run until either there are no remaining life cells, or the population remains unchanged for 10 generations. (You may want to write a census() method to count the number of live cells in the grid.)

Some help:

To help you along, we have provided the ScoreBoard classes from Lab9. These will provide a good windowing foundation for your Life game. While they are more fully described in the lab write-up, remember that these class files are:

Showlights.java
Board.java
Cell.java
ScoreBoard.java

ScoreBoard is the class that should hold the bulk of the code for the lab. You'll want to convert this into your controller for the Game of Life, so you should rename it to Life.java for this assignment. (You'll have to change your driver, Showlights so that it calls this new file, but that's fine. The driver that I'll use will have that change as well (as many times as necessary, but only that), to meet the assignment specifications.

Remember, the code for all the above can be found via links at: http://www.csc.calpoly.edu/~csturner/courses/101/Labs/Lab9/lab9_life.html


Some Additional Notes on the Task


Submitting Your Work

Use the "handin" facility available from your Central Unix account on Polylog1 to submit these required files to the Pgm6 folder for your section:

Required (all teams or individuals must submit their own copy of these files):

Do not submit the corresponding .class files (the course account does not have enough space for all of those!); instead, we'll automatically compile them from the .java files you do submit. Note that you must use the exact names specified above for our automatic processes to work. If your filenames differ in any way from those indicated, or if your files do not compile, they will not be graded.)

It is expected that your source code will contain full internal documentation. Use the standard comment block at the beginning of the program for your design specifications and other general information. Use comments throughout your programs to clarify to anyone reading your program what you are doing at each step along the way. If you have additional comments to make, you may submit a supplemental README document, in plain text format, but its existence must be documented in the program file you submit. If you don't understand the expectations here: talk with some classmates, see your instructor during her regular office hours, or make an appointment with your instructor for a time well in advance of the due date.


Site Navigation Links:
Back: This Instructor's CSC-101 HomePage
Up: This Instructor's HomePage

Copyright © 2000 by Carol Scheftic and Phil Nico and Clark S. Turner, 2003. All rights reserved.
Requests to reuse information from this page should be directed to Carol Scheftic.
Page created 1 April 2001; last updated May 2003.