CSC 8310 -- The Life Program

Dr. David Matuszek,   dave@acm.org
Fall 1998, Villanova University

John Conway's Game of Life is not what most people would consider a "game." Like Wator, you set up the initial conditions and then just watch and see what happens.

Like Wator, Life is played on a checkerboard of arbitrary size. Each cell of the checkerboard is considered to have eight neighbors. A cell is either occupied ("alive") or not occupied ("dead"). At each step, or "generation", whether a cell is alive or dead depends on whether it was alive or dead in the previous generation, and on how many neighbors it had. Specifically,

I wrote a Life program, first as an application, then I turned it into an applet. This program is similar in many ways to your Wator assignment. All the code is presented below; feel free to mine it for ideas, or even borrow large chunks of it, in writing your Wator assignment.

If you find any problems (other than those mentioned in the descriptions), please let me know. Thanks!

Back to syllabus

Link Added Features
Version 0 The original application, not an applet at all.
Version 1 This version just sets up a "Hello, Web!" applet.
Version 2 The paint routine is modified to display something more like the final product.
Version 3 The init method is introduced to initialize the array, and the paint method is modified to just do the painting.
Version 4 This version adds a button. To put the button where we want it (so that it doesn't get covered over by ovals), we introduce a layout manager. The layout manager, in turns, forces us to use a canvas.
Version 5 Gets the size of the canvas and uses it, rather than assuming the size of the applet. Requires Java 1.1 or better.
Version 6 Make the button "Step" button active. This involves adding an ActionListeneractionPerformed.
Version 7 Merge in the code for the actual Life game, wreaking havoc and causing changes too numerous to mention.
Version 8 Create a separate thread to run Life, so that we can change the "Step" button into a "Stop/Go" button.
Version 9 Add the ability to click on any cell on the board to change its color.
Version 10 Final version. Add some handy buttons and some TextField controls.