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.
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). } } }
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:
This file is a 12 by 12 matrix with 200 generations