Conway's Game of Life in Parallel
also Sharks and Fishes as a variant

  • Background material

    lifeTemplateSerial.c: This serial version - non parallel - of a shell program writes the output of each generation to the screen. board.txt is read as an initializer to the grid. You need to complete the golife and checkneighbors functions for this program to do anything. (see below)
    board.txt: an example starter board with patterns for the Life game.

    lifeTemplateMPI.c: This MPI version of a shell program writes the output of each generation to a text file.
    board.txt: an example starter board with patterns for the Life game.

  • Assignment

    1. First you need to complete the golife and checkneighbors functions (a variation of these can be done for Sharks and Fishes):
      
      void checkneighbors(struct individual board[ROWS][COLS], int rows,
                                   int cols)
      {
              int row, col;
      
      // Check the 1st and last rows, the 1st and last columns
      // and the internal cells of the matrix (those not on the borders)
      
      }
      
      
      void golife(struct individual board[ROWS][COLS], int rows, int cols)
      {
              int row, col;
              int count;
      
              for(row=0; row<rows; row++) {
                      for(col=0; col<cols; col++) {
                              checkneighbors(board, rows, cols);
      						
                  //Count the number of neighbors for each cell
      			
      				}
              }
              for(row=0; row<rows; row++) {
                      for(col=0; col<cols; col++) {
       				
      // A dead cell with exactly three live neighbors becomes a live cell (birth).
      // A live cell with two or three live neighbors stays alive (survival).
      // In all other cases, a cell dies or remains dead (overcrowding or loneliness).
      			
      		}
              }
      }
      
    2. lifeoutput.txt

      This is the first part of the data file generated by a working version of #1 (a version with the functions golife and checkneighbors completed). The numbers at the beginning of the file are:

      • NumberOfRows NumberOfCols
      • NumberOfGenerations

      This file is a 12 by 12 matrix with 200 generations

    3. I started by using 3 processors, so that a 12 X 12 matrix is divided into 3 matrices, each 4 rows X 12 cols. I chose Life patterns that would oscillate and stay in each of the sections.

    4. The next step is to make each section communicate with each other so that the Life patterns can move and travel among the sections.