CSC 148S

Spring 1998

Introduction to Computer Science

Assignment 1 Messages

Assignment 1
For students using Visual Age for Java.
There are problems detecting the end of file when input is coming from "standard" input -- usually the keyboard. So students using Visual Age for Java for assignment 1, should use the other option and have your input come from a file called LifeInput.
Students who are not using Visual Age for Java should read the later messages in this page for details regarding running your program with input from "standard" input.

Assignment 1
There have been questions regarding how to implement deleting a CellInfoNode. Some students think they have to find the previous node (by iterating from the front of the list for each deletion) in order to get at and change its link.
There is a better way. Remember the "location" of the previous CellInfoNode by storing a reference to the previous CellInfoNode as one traverses the list of CellInfoNodes.

Assignment 1
Students have asked whether the cells should evolve in their solution. Yes, this should happen while you "prune" the nextInfoList of cells that died and update CellInfoNodes in the nextInfoList for cells that are born also update theGrid LiveCells for cells that continue living.

Assignment 1
There was a question regarding removing a CellInfoNode (c) from the nextInfoGrid when c is removed from the nextInfoList if it does not have the appropriate number of neighbours. The algorithm just says to remove c from the nextInfoList. You can also remove c from the nextInfoGrid but this is not necessary since we never use the nextInfoGrid again in the algorithm. The nextInfoGrid is used in building the nextInfoList but once the nextInfoList is built the nextInfoGrid is not needed and is discarded when the nextInfoList becomes theInfoList and the algorithm starts building a new nextInfoList and new nextInfoGrid.

Assignment 1
There is an error in the display method of the starter code. The pretty display draws the grid on its side (reflected in the diagonal--the row and column coordinates are reversed). There are two ways to correct this problem:
1. If you have not started work on the assignment as yet, pick up a new copy of the Grid class.
2. Replace the display method in your Grid class by this correction.

Assignment 1
Here is a correction to the algorithm in the assignment. It does not handle CellInfoNodes for unoccupied cells that are added to the next generation's information list because they are cells with occupied neighbours but should be removed from the list when the list is being pruned of all cells that should not be live in the next generation because they don't have the right number neighbours to have a birth. In otherwords they are unoccupied in the current generation and should remain unoccupied in the next.

The problem is in the for each loop near the end of the algorithm. The if immediately after the for each should read:
if c does not have the appropriate number of neighbours to be a LiveCell

Assignment 1
Here is further information regarding the command line options for assignment 1. Contrary to the information in the assignment description, the "nodelay" and "none" options with TimeOfYourLife.java are equivalent. Either will produce only the timing information at completion of the program. There is no need for you to make any changes to the TimeOfYourLife.java file.

Think about why the timing results of running the program with the new version of the grid would not be greatly improved when compared with the timing results of the old version of the grid when the runs include output of the grid.

Assignment 1
The following describes the command line options available when running the program.

When running the Life program there are two sets of possible command line arguments.
The first argument indicates where the input comes from. There are two possible argument values: "standard" and "file". The "standard" argument instructs the program to read input from the keyboard (or redirected from a file--more about this later in this advice page.) The "file" argument instructs the program to read input from a file. The program opens a dialog box requesting an input file name.
The second argument indicates what sort of output to produce. There are two possible argument values: "text" and "pretty". The "text" argument tells the program to produce text output. The "pretty" argument tells the program to produce graphics output. If neither "text" or "pretty" is used the program will produce both types of output.

Students who are working in a non-windowing environment will be restricted to text output. Their program will also not work for the "file" argument. There is a way around the "file"/"standard" argument restriction. Your program can still read data from a file by redirecting standard input as follows:
java Life standard text < LifeInput

Assignment 0 messages have been moved.