Machine Problem 4, due Nov 10

Part of the assignments for 22C:60, Fall 2004
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

All assignments will be due at the start of class on the day indicated, and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.

  1. Conway's Game of Life, part II

    Your code for Machine Problem 1 is most likely to be somewhat inflexible, enforcing only one set of rules for Conway's Game of Life. Consider the following observation. A cell in the Game of Life has 8 neighbors:
    123
    4x5
    678

    These neighbors are not all equidistant from the cell, if we use Euclidian distances. If neighbors 2, 4, 5 and 7 are one unit of distance away from the central cell, then neighbors 1, 3, 6 and 8 are about 1.414 units away. Therefore, shouldn't we weight their influence proportionally less?

    If the influence of a cell follows an inverse square rule, then we should weight the diagonal neighbors half of what we weight the immediate neighbors. In the general case, we could describe a weighting of neighbors with a template such as:
    00100
    02420
    14x41
    02420
    00100

    The above template is based on the inverse square rule, extending out to a radius of 2, and ignoring all cells outside that radius.

  2. Prepare for Generalization

    Rewrite (or write anew) your solution to the previous machine problem so that the code for running the game is split into two separately assembled units, one part being a subroutine that, given a pointer to a cell in the playing field, is concerned solely with computing the number of living neighbors of that cell and determining the next state from this number. All of the mechanics of initialization, iteration and display of the game board should be in the in the other source file

  3. Generalize the initialization

    Also rewrite the board initializer so that it accepts a separately assembled file describing the initial board configuration, where configurations are described by a sequence of pairs of bytes such as the following:

    	INT	INIT
    INIT:   B  0, 0   ;  put X at the center of the screen
            B -1,-1   ;  put X diagonally to the left above the first
            B  0,-1   ;  put X straight above the second one
            B  2, 0   ;  put X 2 spaces right of the third one
    	B  0, 0   ;  quit
    

    Note the termination marked by a pair of zeros and that this file is also separately assembled from your primary source file.

    This generalization is useful because, for different next-state rules, there will be different configurations that lead to interesting behavior.

  4. Finally

    Modify your "next state" module to compute the next state using the weights suggested above, with quadratic fall-off to a weight of 1 at radius 2. If the total weight of the neighbors is below 9 or above 16, the cell should die. Births should occur if the weight is in the range 12 to 16.

    Revisions to these specific thresholds may be announced, particularly if we find thresholds that lead to really neat behaviors.

  5. Submit

    Your solution must be contained in a directory called mp4; this directory should contain exactly 3 SMAL Hawk source files, main.a, rules.a and init.a. Your file init.a sould be some variation on the init.a file given above; you are welcome to make a much more complex initial configuration.

  6. Grading

    We will assemble your main.a and rules.a with our own init.a for grading. A solution that runs under the conventional rules of Conways Game of Life will be worth, at most, half credit. Full credit will be available only to those who implement the new quadratic neighborhood rule described above.

    Given that your solution works, grading will be based on the clarity of your code and correctness of your modularization.