Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language Game of Life For example: Welcome to Game of Life Enter the n for the nXn grid to simulate(max size=50): 10 Enter the

image text in transcribed

C language Game of Life

For example: Welcome to Game of Life Enter the n for the nXn grid to simulate(max size=50):10 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

Enter the number of time steps you wish to simulate, (max size=50): 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

Game of Life: C Program Life takes place on a two-dimensional grid of cells. Each cell can be either alive or dead (full or empty). Every cell interacts with its 8 neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent At each step in time, the following transitions occur: 1. Any live cell with less than two live neighbors dies, as if caused by underpopulation. 2. Any live cell with two or three live neighbors lives on to the next generation. 3. Any live cell with more than three live neighbors dies, as if by overpopulation. 4. Any dead cell with only three live neighbors 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 seed and births and deaths occur. 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 size of the grid and the number of timesteps should be determined by the user Code must have a 3-D array declared in main of size [MAXSIZEIMAXSIZE[MAXTIME+1], where MAXSIZE is 50 and MAXTIME is 50 Code must include these two functions: int neighbors(int anccavIMAXSIZE] [MAXSIZE] [MAXTIME+1], int i int j. int size, int step) /I returns the nu mber of neighbors of position that are alive at time step void Rrantrid4nsmxacad[MAXSIZE] [MAXSIZE] [MAXT IME-1],ansase.. anstep) /I print the grid of size x size at time step. Game of Life: C Program Life takes place on a two-dimensional grid of cells. Each cell can be either alive or dead (full or empty). Every cell interacts with its 8 neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent At each step in time, the following transitions occur: 1. Any live cell with less than two live neighbors dies, as if caused by underpopulation. 2. Any live cell with two or three live neighbors lives on to the next generation. 3. Any live cell with more than three live neighbors dies, as if by overpopulation. 4. Any dead cell with only three live neighbors 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 seed and births and deaths occur. 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 size of the grid and the number of timesteps should be determined by the user Code must have a 3-D array declared in main of size [MAXSIZEIMAXSIZE[MAXTIME+1], where MAXSIZE is 50 and MAXTIME is 50 Code must include these two functions: int neighbors(int anccavIMAXSIZE] [MAXSIZE] [MAXTIME+1], int i int j. int size, int step) /I returns the nu mber of neighbors of position that are alive at time step void Rrantrid4nsmxacad[MAXSIZE] [MAXSIZE] [MAXT IME-1],ansase.. anstep) /I print the grid of size x size at time step

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

Step: 3

blur-text-image

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

How many US courts of appeals does the federal court system have

Answered: 1 week ago