Question: In C, Implement Conways Game of Life. Using linked-lists, pointers, and I/O files NOT arrays. The primary data points will be stored in a file

In C, Implement Conways Game of Life. Using linked-lists, pointers, and I/O files NOT arrays. The primary data points will be stored in a file then each value in grid is allocated dynamically, then referenced using a pointer in a linked list. Here are general steps:

a. Input the file.

b. Make the 1st line listing the number of time steps to simulate.

c. Make 2nd line the number of rows followed by the # of columns in the grid to be simulated then the rest of the lines in the file will have the positions of the initial cells that are "alive"

d. Make linked list of nodes allowing every node to be a single time-step (the start pointer should point to the initial grid, and each time step should follow.

Do not use arrays instead allocate memory dynamically with pointers

Create linked list node using the stuct:

struct link_node {

int rows;

int columns;

int * gridd; //the pointer to grid that with size rows*columns

struct link_node *next_step; //the pointer to node that has grid for next time-step

};

You MUST create the following functions:

struct link_node *makeNode(FILE *inputf, int *nsteps); // reads data from file pointers input, makes node with the data and # of time steps in nsteps
void nextnStep(struct link_node *start); // adds a struct node to end of the list pointed to by start for the next time step, use the data in the last nod of list to make the new timestep. 
void printTheList(struct link_node *start); // prints all of the grids in the list pointed by start.

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

Example of input file thesampleinput.txt contains:

3 10 12 7 7 7 8 7 9 8 7 9 8

So code should display the following:

Welcome to Conway's game of Life Please enter filename 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000011100 000000010000 000000001000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000001000 000000011000 000000010100 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000011000 000000010100 000000010000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000000000 000000011000 000000110000 000000001000 000000000000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!