Answered step by step
Verified Expert Solution
Question
1 Approved Answer
LIFE is an organism that lives in a discrete, two-dimensional world. This world is a 2D array (r by c) of characters with each cell
LIFE is an organism that lives in a discrete, two-dimensional world. This world is a 2D array (r by c) of characters with each cell capable of holding one LIFE cell. Generations mark the passing of time. Eaclh generation brings births and deaths to the LIFE community. The births and deaths follow the following set of rules We define each cell to have eight neighbor cells. The neighbors ofa cell are the cells directly above below, to the right, to the left, diagonally above to the right and left, and diagonally below to the right and left. Be careful when checking for neighbors on the edges, e.g., a corner cell has three neighbors (see Figure 1). You can receive 20% bonus points if you count eight neighbors for all cells by making the edges of your world wrap-around (see Figure 2) . Figure l: neighbors oftwo cells in a5 by 6 world without wrap-around edges Figure 2: neighbors ofa cell in a 5 by 6 world with wrap-around edges If an occupied cell has zero or one alive neighbors, it dies of loneliness. If an occupied cell has more than three alive neighbors, it dies of overcrowding If an empty cell has exactly three alive neighbor cells, there is a birth of a new cell to replace the empty ceil. . Births and deaths are instantaneous and occur at the changes of generation. A cell dying for whatever reason may help cause birth, but a new born cell cannot resurrect a cell that is dying, nor will a cell's death prevent the death of another, say, by reducing the local population. Figures 3 and 4 are examples of static worlds, meaning they do not change at the change of generations. While figure 5 shows a self-repeating world. Figure 5: example ofa static worldFigure 4 : example of a static worldFigure 3:eample of selfrepeating world You will write a program to simulate this world. You can work on the template provided on Carmen (wherever you see /*your code here*/, replace it with your code). This template uses 2D dynamic arrays to store the world, you can also use 2D vectors, more details in Activity 1. You should first read the dimensions (r and c) of the world and create two 2D arrays with those dimensions, one original world and
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