CS 340

Machine Problem 6, Fall 2001

Game of Life

Due: Tuesday, November 27, 2001 at 11:59 pm

For this assignment, you are to create a Java application using the Java Swing Graphical User Interface elements to play John Conway's Game of Life. This "game" was designed to show how a cell will spread out in its environment over numerous generations. The link gives much more information than you will probably care about, but it does contain an applet that shows how the game can be played. This assignment is a simplification of the applet shown. This assignment also has specific requirements about the layout of the GUI which differ from the applet.

The Game of Life is to be played on an infinite two dimensional grid. For this assignment, we will restrict the grid to a finite size of at least 15x15. You can make your grid larger than this if you want, but it is to have finite size. In this grid, cells are born, survive or die from one generation to the next. Whether a cell is born, survives or dies depends on how many cells are living in the neighboring grid positions. A cell has eight neighbors, except those cells on the edge of the grid. A cell in a corner of the grid has three neighbors and a cell on a non-corner edge has five neighbors. When calculating the number and positions of cells in the next generation, the number of neighboring cells in the current generation must be known.

For this assignment, your application will need three different areas where the user can interact. The first area is a menu bar. The second area is the rectangular grid of cell positions. The third area is a control area.

The rectangular grid of cell positions is to be made up of buttons. The buttons are to display information showing that either a cell is "living" in that position or it is not "living" in that position (the position is "dead"). You can use any method you like to show this difference (this can include icons, colors or text). When one of these buttons is clicked, a "dead" position becomes a "living" position and a "living" position becomes a "dead" position.

The menu bar is to contain 3 drop-down menus called File, Edit and Help. The File drop-down menu is to have three menu items: Open, Save as and eXit. The Edit drop-down menu is to have three menu items: Clear, Set and Random. The Help drop-down menu is to have two menu items: Help and About. All words in the menus are to have the mnemonic set to the shown capital letter. Note: you are allowed to change the Help menu item to heLp. The menu items are to perform the following functionality:

The control area of yor program is to contain three buttons and a JSlider. The first button is to step the grid from one generation to the next. The next two buttons are to start and stop the continuous updating from a current generation to the next generation. The speed of the continuous updating is to be controlled by the JSlider element. At one end, the updating should be done slowing (about once every 2 second). At the other end, the updating should be done quickly (about 20 times a second). Your control area must include some labels that make the use of your program obvious.

A makefile is not required, but the program is to be compiled with the command of:

     javac mp6.java
and executed with the command of:
     java mp6

This program will also require a 1-2 page write up of the code structures used in the program. Remember that this write-up is to be written in ASCII format and is to be electronically turned in with your program. The name of this file should be "readme.txt". Also recall that your program will be given to another student to write a critique. Therefore, it is suggested that you do not include your Social Security Number in your program. Instead use your name and your CS User ID to identify yourself.

Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.

The work you turn in must be 100% your own. You are not allowed to share code with any other person (inside this class or not). You may discuss the project with other persons; however, you may not show any code you write to another person nor may you look at any other person's written code.

You are to submit this project using the CS Department's UNIX machine's turnin command. The project name for this assignment is mp6. Be sure to submit all source code, header files as well as your program description. Failure to turnin all required pieces will result in a lower grade for the assignment.