Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Game of Life was invented by Cambridge mathematician John H. Conway to model the process of birth, survival and death. By the rules of
The Game of Life was invented by Cambridge mathematician John H. Conway to model the process of birth, survival and death. By the rules of the game, individuals r equire others to survive, but die as the result of ng. For our world, we will use a 3-dimensional array of chars (think of this as two layers of 2-dimensional arrays of chars) (minimum size: 2 x 20x 40). One level will be the current world, the other will hold the next generation. Each cell in the array holds either a"" (a live organism) or a blank-- " "--(no organism). The game starts out with an initial generation, which consists of any mix of stars and blanks. This original array will be read in from a text file specified by the user. The program should allow this to come in from the command line as well as from within the program. This file can be created using any text editor, such as notepad (do not use a word processor!) Three rules govern the transition from one generation to the next: a. Birth Rule: an organism is born into an empty cell that has exactly three living neighbors. b. Survival Rule: An organism survives from one generation to the next if it has either 2 or 3 living neighbor c. Death Rule: An organism dies from loneliness if it has fewer than 2 neighbors. It dies from overcrowding if it has 4 or more neighbors. A neighbor of a cell is any of the 8 possible cells that touch it. In the array to the left, the cells labeled "x" are all neighbors of the cell marked*" Be careful when looking at the cells at the edge of the world. Do not go out of bounds! In your version of the game, you will display the world one generation at a time, clearing the screen between each generation. The user will press Enter> to continue, and some other key to quit. Make Sure you test fully! Results depend on the initial colony. Some possible results The colony quickly dies out .The colony rapidly expands (stopped only by the edge of the world). . the colony reaches a set stasis the colony reaches an oscillating stasis (moves back andforth between 2 or more configurations) The program, of course, should use top-down design, and must utilize modularly designed functions. Some suggestions for functions you should utilize: a function to read the file into the gri
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