[Santa Clara University]
Department of Mathematics
and Computer Science

Machine Problem 3

Math 60 -- Winter, 2006
D. C. Smolarski, S.J.

              
20 points
DUE: NOON: Wednesday, February 8, 2006

I assume you will create a new subdirectory for this program, as I suggested for the first two programs, and also create a new makefile.

The game of Life (cf. John H. Conway, Scientific American, Oct. 1970, p. 120) is supposed to model the genetic laws for birth, survival, and death. One "plays" it on a chess-like board. Each square can be empty or contain an X indicating the presence of an organism.

Note that each square (except the border squares) has eight adjacent squares or "neighbors."

The next generation of organisms is determined according to the following "laws":

  1. BIRTH: An organism will be born in each empty location that has exactly three neighbors.
  2. DEATH: An organism with four or more organisms as neighbors will die from overcrowding. An organism with fewer than two neighbors will die from loneliness.
  3. SURVIVAL: An organism with either two or three neighbors will survive to the next generation.
Write a Fortran-90/95 program to play the Game of Life. Try to make use of various Fortran-90/95 array features to minimize your code. Also make use of subprograms, at least one to print out the game-board.

Use a 15 by 15 "game board." Print out the game board for the next 12 generations after printing out the initial configuration given below, trying to get as many on a page as possible (probably only 3).

HINTS:

  1. Use two 2-dimensional arrays, both of type INTEGER, as internal "work arrays." Use one as the current game board and one as the work area to determine the next generation--then copy the new generation to the game board. These are internal "work" arrays since you will not print out either of these INTEGER arrays.
  2. You can indicate the "presence" of an organism by putting a 1 in a square (i.e. array place) and the "absence" by a 0. Thus, by summing the values of the neighbors of a given square, one can determine the number of neighbors. Do not complicate unnecessarily the code for summing these values (i.e., don't use any loop to compute these numbers)!
  3. Don't fall off the board (i.e. be careful of invalid, out of range, subscript values).
  4. Assume that the borders of the board are infertile regions where organisms can neither survive nor be born. Therefore you do not have to process the border squares.
  5. To print out the board, create a new CHARACTER array of .'s and X's where a . corresponds to a 0 in the work arrays and an X to a 1.
For the starting configuration, assume that there are organisms in the following locations:
	(3,4), (4,5), (5,3), (5,4), (5,5), (11,11), (11,12),
	(11,13), (12,11), (13,12)
NOTE: Use good style, label the output, use plenty of comments! Remember that you can get points taken off a program that gives a correct answer if there are little or no comments in the code and the output is not labeled!

Turn in the source file (i.e., the program code file) and the output file. This can be done by using the Unix command

     enscript mp3.f90 mp3ou.out
(assuming these are your actual filenames) (or you can use the "fancier" enscript as in MP 1 instead).

As with the previous programs, your sheets may be turned in to my office, O'Connor 32, or to my mailbox in O'Connor 31. Please staple the pages yourself and do not turn in disconnected pages!


This page is maintained by Dennis C. Smolarski, S.J. dsmolarski@math.scu.edu
Last changed: 3 January 2006.