Question
Please anyone who can do this problem using c programing? The Game of Life, invented by John Conway in 1970, is an example of a
Please anyone who can do this problem using c programing?
The Game of Life, invented by John Conway in 1970, is an example of a zero-player game known as a cellular automaton. The game consists of a two-dimensional world extending infinitely in all directions, divided into cells. Each cell is either dead or alive at a given generation. The game consists of a set of rules that describe how the cells evolve from generation to generation. These rules calculate the state of a cell in the next generation as a function of the states of its neighboring cells in the current generation. In a 2-D world, a cells neighbors are those 8 cells vertically, horizontally, or diagonally adjacent to that cell. Conways set of rules are summarized as:
A live cell with fewer than two live neighbors dies.
A live cell with more than three live neighbors also dies.
A live cell with exactly two or three live neighbors lives.
A dead cell with exactly three live neighbors becomes alive.
In this lab, you will implement Conways Game of Life, with the minor restriction that our 2-D world is finite. The neighbors of a cell on the edge of the world that would be beyond the edge are assumed dead. You can read more about Conways Game of Life on Wikipedia at http://en.wikipedia.org/wiki/Conways_Game_of_Life.
You will implement a game of size 40 (width) by 30 (height).
You will start the game by setting 5 states to be alive, and all other states to be dead. The alive cells are located at (1, 2), (2, 3), (3, 1), (3, 2), (3, 3).
You will use a 2D array to represent the state of the game, and another 2D array to represent the next generation of the game.
You will implement a method called next_generation(), which computes the state of each cell based on the rules above, stores the results in the 2D array that represents the state of next generation.
After the next_generation() is executed, you should set the current state of the game based on the results generated from the next_generation(). You can do this by copy the state of each cell from the next generation 2D array to the current state 2D array.
In the function next_generation(), you should call function (that you will define and implement) get_next_state(x, y) to compute the state of cell at (x, y) in next generation, based on the number of alive neighbors, which you can inquiry by call function alive_neighbors(x, y) (which you will define and implement).
You should be able to output the state of the game, by printing text in the console. For each row of the game, two adjacent cells are separated by symbol "|". If a cell is alive, you print a "*", and "_" otherwise.
In the main function, you will implement the game to execute 50 generations, print out the result.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started