Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objective: Learn how to use pointers Specifications: For this assignment you wil

ID: 3529362 • Letter: O

Question

Objective:
Learn how to use pointers
Specifications:
For this assignment you will be implementing the classic cellular automata of Conway's Game of Life.

Rules:

1. A new cell is born on an empty square if is surrounded by exactly three neighboring cells
2. A cell dies of overcrowding if it has four or more neighbors
3. A cell dies of loneliness if it has zero or one neighbor
4. Any live cell with two or three live neighbors lives, unchanged, to the next generation.

Implementation details:
The initial state of the game is held in a text file named the driver code and attached to this assignment (you must use this driver program). The format will be sequences of ones and zeros. A one means that a cell is living in that square. You will determine the size of the grid display by reading the first line of the text file and seeing how many columns you will need. You will determine the number of rows in the grid by counting the lines of data.

Exampled:

00000000100000001010
00000000010000001001
11100000010100000010
10100100101010101010
00101010010010101000

The grader will use a file with arbitrary grade size to grade the project. You algorithm should be able to handle this.

Example: Jeremy Allen's Glider Gun fight grid (set the iterations to 500).

Note: When printing out the status of the grid, print one character to standard output per cell in the automaton. You may use whatever characters you wish to show the status of the cell. The driver program will clear the screen between generations.
In this project you will have three files -

1) "life.h" will store the prototypes of all functions that are employed in the workings of Game of Life

2) "life.cpp" will store all headers and definitions of the functions identified in "life.h"

3) "life_driver.cpp" - this is a given file that tests the functionality of your game of life.

To compile all three files you need to add them to a project in
Dev C++ environment.

( THE FILES ARE BELOW AT THE END OF THIS ASSIGNMENT.)

Note: when you submit your life.h and life.cpp they should work with default life_driver.cpp file.
It means that you cannot make any changes to life_driver.cpp except the value for
NUM_GENERATIONS for debugging purposes.

NOTES: DO NOT USE "CLASS" THAT IS USED IN DATA STRUCTURE. AND PLEASE DO NOT USE STRING. USE CHARACTERS INSTEAD OF STRINGS.


Make sure:

1) Code compiles

2) Following functionality is tested

a. ShowWorld() function works correctly

b. iterateGeneration() function works correctly, i.e., correct cells become alive and

correct cells die

c. the program can handle input of an arbitrary size by using two dimensional

dynamic arrays

3) Comments are present in the code

4) Code styling margins (lines of the code are not too long), readability (code is not

cluttered and follows style standards for the class )

5) Code efficiency: code is concise and no unnecessary conditional, interactive and

sequential statements are employed considering the implementation requirements and

constraints outlined by the project


Penalty: (SO THINGS TO AVOID)

1) Non-default life_driver.cpp has to be employed for the program to work

2) Dynamic arrays should go and shrink with each generation as new live cells appear and

disappear. Only single boundary of dead cells around the live cells is allowed when the

new generation is displayed or written to a temporary file. If this functionality is not

implemented

3) If string objects are used

----------------------------------------------------------------------------------------------------
FILES:

1) THE DRIVER CODE (TXT FILE): glider_gun_fight.txt

0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000010000000000000000000000000000000000000000000
0000000000000000000000000000001010000000000000000000000000000000000000000000
0000000000000000000011000000110000000000001100000000000000000000000000000000
0000000000000000000100010000110000000000001100000000000000000000000110000000
0000000011000000001000001000110000000000000000000000000000000000000110000000
0000000011000000001000101100001010000000000000000000000000000000000000000000
0000000000000000001000001000000010000000000000000000000000000000000000000000
0000000000000000000100010000000000000000000000000000000000000000000000000000
0000000000000000000011000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000001110000000
0000000000000000000000000000000000000000000000000000000000000000010001000000
0000000000000000000000000000000000000000000000000000000000000000100000100000
0000000000000000000000000000000000000000000000000000000000000000100000100000
0000000000000000000000000000000000000000000000000000000000000000000100000000
0000000000000000000000000000000000000000000000000000000000000000010001000000
0000000000000000000000000000000000000000000000000000000000000000001110000000
0000011000000000000000111000000000000000000000000000000000000000000100000000
0000011000000000000000101000000000000000000000000000000000000000000000000000
0000000000000000000000110000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000011100000
000000000000000000000000000000000000000000000000000000000000000000001110000
0000000000000000000000000000000000000000000000000000000000000000000100010000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000001100011000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0001100011000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000100010000000000000000000000000000000000000000000000000000000000000000000
0000011100000000000000000000000000000000000000000000000000000000000000000000
0000011100000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000110000000000000000000000
0000000000000000000000000000000000000000000000000001010000000000000001100000
0000000010000000000000000000000000000000000000000001110000000000000001100000
0000000111000000000000000000000000000000000000000000000000000000000000000000
0000001000100000000000000000000000000000000000000000000000000000000000000000
0000000010000000000000000000000000000000000000000000000000000000000000000000
0000010000010000000000000000000000000000000000000000000000000000000000000000
0000010000010000000000000000000000000000000000000000000000000000000000000000
0000001000100000000000000000000000000000000000000000000000000000000000000000
0000000111000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000001100000000000000000000
0000000000000000000000000000000000000000000000000000100010000000000000000000
0000000000000000000000000000000000000000000100000001000001000000001100000000





---------------------------------------------------------------------------------
2)NAME: life.cpp


//This file provides the implementation of the life.h header file.


#include <iostream>
#include <fstream>
#include <string>

#include "life.h"

using namespace std;

//GLOBAL VARIABLES

int ROWS; //stores the number of rows in the grid
int COLUMNS; //stores the number of rows in the grid

//This function reads input file for subsequent prosessing (add high level
//description of your implementation logic)
void populateWorld (const string file)
{

}

//This function outputs the grid for current generation (add high level
//description of your implementation logic)
void showWorld ()
{

}

//This function creats new geneneration grid from the old generation grid
//(add high level description of your implementation logic)
void iterateGeneration ()
{

}





-------------------------------------------------------------------------------
3) NAME: life.h


//This header file provides the prototypes of the function definitions
//for the project.

#ifndef life_h
#define life_h

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

void populateWorld(string file);
void showWorld();
void iterateGeneration();

#endif







------------------------------------------------------------------------------

4) NAME : life_driver.cpp


/// This is driver's code



#ifdef linux

#define LINUX true

#define WINDOWS false

#endif


#ifdef __WIN32__

#define LINUX false

#define WINDOWS true

#endif



#include <iostream>

#include <fstream>


#include "life.h"


const char FILE_NAME[] = "glider_gun_fight.txt";


using namespace std;


const int NUM_GENERATIONS = 10; //set to a smaller number for debugging


int main()

{

populateWorld(FILE_NAME);

showWorld();


for (int iteration = 0; iteration < NUM_GENERATIONS; iteration++)

{

if (WINDOWS)

system("cls"); //Windows only

else

system("clear"); //Linux only

iterateGeneration();

showWorld();

}


if (WINDOWS)

system("PAUSE");

return 0;

}

Explanation / Answer

True