Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C LANGUAGE CONWAY'S GAME OF LIFE The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells , each

IN C LANGUAGE

CONWAY'S GAME OF LIFE

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead, or "populated" or "unpopulated". Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.

Any live cell with two or three live neighbours lives on to the next generation.

Any live cell with more than three live neighbours dies, as if by overpopulation.

Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seedbirths and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

Your project is to create a game of life on a 2-d grid that will be no more than 50 x 50.

Your code should be able to simulate and display up to 50 timesteps.

The exact size of the grid and the number of timesteps to be simulated will be specified by the user.

Your code must have a 3d array declared in main of size [MAXSIZE][MAXSIZE][MAXSTEPS+1], where MAXSIZE is 50 and MAXSTEPS is 50

Your code must include the following two functions

int neighbors(int anArray[MAXSIZE][MAXSIZE][MAXTIME+1], int i, int j, int size, int step) // returns the number of neighbors of position i,j that are alive at time step. void printGrid(int myGrid[MAXSIZE][MAXSIZE][MAXTIME+1],int size,int step) // print the grid of size sizexsize at time step. 

For example:

Welcome to Connor's game of Life

Please enter the n for the n by n grid to simulate, max size for n is 50. :10

Thank You, now enter the initial x y coordinates (the board is indexed starting from 0 0) for the initial live cells, enter

-1 -1 when done

7 7

7 8

7 9

8 7

9 8

-1 -1

Please enter the number of time steps you wish to simulate, max number allowed is 50. 12

Num time steps 12

After 12 timesteps the grid is:

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 0 1 1 1 0 0 0

0 0 0 0 1 0 0 0 0 0

0 0 0 0 0 1 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

Let A be an n n matrix such that ||A|| Answered: 1 week ago

Answered: 1 week ago

Question

Deliver the bad news in the most acceptable manner possible.

Answered: 1 week ago

Question

1. What is the tone of the comments? How can they be improved?

Answered: 1 week ago

Question

1. Identify six different types of history.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago