Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Option 2: Conwav's Game of Life Your task is to write a program that plays Conway's Game of Life (for details and ex amples, see
Option 2: Conwav's Game of Life Your task is to write a program that plays Conway's Game of Life (for details and ex amples, see https://en.vikipedia.org/wiki/Convay's.Game of Life). The basic gam ts played on each generation, each cell changes according to the following instructions: nal grid of square cells, each of which is either alive or dead. With 1. Any dead cell with exactly three live neighbors (out of its eight nearest neighbors) comes to life [reproduction]. 2. Any live cell with fewer than two live neighbors dies (underpopulation). 3. Any live cell with more than three live neighbors dies (overpopulation). 4. Any live cell with two or three neighbors continues to live. The output of the game is therefore entirely determined by its initial state, which you may represent in terms of a matrix whose entries are all 0/1. The details of the program are up to you (whatever makes for an interesting result), but consider the following choices: 1. You will probably want to keep track of two matrices: one (e.g. thisGen) with the information for the current gencration, and one (c.g. nextGen) where you define in- formation for the next generation. Then swap them with thisCen nextGen; and repeat. 2. The grid may be infinite (where your matrix has to get larger over time), finite with a boundary, or toroidal (if an object moves off the right side of the screen, it reappears on the left side). 3. Include some functions that allow the user to progress g gencrations with frame rate r, then stop and await further instructions. (This as an alternative to running the program a fixed number of generations before quitting, or to running indefinitely). 4. Include some functions that allow the user to manually change the living/dead state of some of the cells. 5. Allow the user to upload an arbitrary matrix pattern for the initial state. 6. Allow the user to save the current state so that they can retrieve it at a later time. 7. Allow the user to save some portion of the animation as a GIF
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