Menu

[solved]-Write Program Implements Game Life Cellular Automata System Invented John Conway 1 Create Q39023654

Write a program that implements the Game of Life cellularautomata system invented by John Conway. 1. Create two game gridsof size at least 50×50. These grid cells can be either Boolean orinteger – probably start with Boolean values. In the following,I’ll refer to these two grids as gridOne and gridTwo. 2. Start byinitializing gridOne. Allow the user to specify two different waysof initializing the grid: 1) by specifying a pattern file to reador 2) by randomly initializing some percentage of the grid cells.One or more sample life pattern files are included in the homeworkfolder on eLearning. One is named GosperGliderGun.txt, as we sawduring class. Use this file to start, but you can download otherfiles from the web and use them for your simulations as well.  Seethe information below on Input. 3. After initializing gridOne,print it to the console and then pause the program so the user canview the game world. Resume when the user enters Y, y, ENTER, orwhatever. 4. Using gridOne, calculate the conditions for all cellsfor the next generation of the game, and store the results ingridTwo. Flip back and forth from gridOne to gridTwo, using onegrid to calculate the other. Print the next generation grid at eachturn, just as we did in the Snake Game or in Wolfram’sone-dimensional cellular automata. In other words, if you’reexamining gridOne, use gridTwo to store the next state of theworld; and if you’re examining gridTwo, store the next state ingridOne. Flip back and forth this way, and print out theappropriate grid at each step. NOTE: Be sure to clear the screenbefore printing out a grid. In Windows, you can use system(“CLS”);.5. Once the simulation begins, the user might want to pause thegame to inspect the state of the cells. Add a pause feature just aswe did in the Snake Game, using _kbhit() from conio.h. Pause whenthe user hits one key, and resume when the user hits another. 6.Make sure you are handling your edge cells properly, but don’t wrapthe world around. Just let edge cells die a lonely death if theywant to. 7. When printing a grid on the user’s screen, use ‘.’ or aspace for dead cells. For live cells, use ‘O’ or ‘X’. 8.Experimenting: Once things are working well, try using larger andlarger grid sizes (or even smaller, if you want). Also, try findingother Life Patterns on the web and running them with your program.And be sure to use some random initializations at some points andplay around with different percentages of initial live cells. Youshould also test your program with the other pattern files I’veuploaded to eLearning. 9. Check out the Life Lexicon athttp://www.conwaylife.com/ref/lexicon/lex.htm for even morepatterns. Game of Life Rules 1. Each cell has at most 8 neighbors(cells on the edge of the world will have fewer): 1 2 3 4 Cell 5 67 8 2. If a cell is alive and has 2 or 3 neighbors, it stays alive.3. If a cell is alive but has fewer than 2 neighbors (0 or 1), thecell dies of loneliness. 4. If a cell is alive and has 4 or moreneighbors, it dies from overcrowding. 5. If an empty cell hasexactly 3 neighbors, it becomes alive. 6. All births and deathshappen simultaneously. Thus, this is a discrete-event simulationsystem. Input: If the user asks you to randomly initialize thegrid, ask the user for a percentage of cells to turn on (e.g., 20or 70, meaning 20% or 70%, etc.). Then go through gridOne turningcells either on or off with that percentage. (Use a random numbergenerator to determine which.) On the other hand, if the user asksyou to initialize the grid by reading from a file, ask the user forthe name of the file. Check for the file’s existence by attemptingto open it for reading. Assume the file is a plain text file thatcontains a Life grid pattern. The file will be in plain ASCIIformat. There can be both comment lines and pattern lines in thefile. Comment Lines: Comment lines will start with the ‘#’ symbol.Read these comment lines and output them to the user. Then skipright past them, as they are only informative comment lines.Pattern Lines: Pattern lines will contain a series of ‘.’ and ‘O’characters. A ‘.’ character indicates that the corresponding cellis dead while a ‘O’ character indicates that the cell is alive.Read each pattern line and set the cells in the corresponding rowof gridOne accordingly. Example Life Pattern File: Here is a sampleof what a Life Pattern file looks like when coded as a plain ASCIItext file: Start loading the pattern into your gridOne at startinglocation something like 10,10 (i.e., don’t start loading thepattern near the edges of your grid.) Make the 10, 10 locationvariable, not hardwired. The reason we load the pattern into anoffset location (e.g., 10,10) is so the pattern won’t be affectedby loading it starting at the top edge of the world. We need toallow room for the pattern to grow and move around, if it wantsto.

C++#Name: Gosper glider gun #Author: Bill Gosper #The first known gun and the first known finite pattern with unbounded growth.

#Name: Gosper glider gun #Author: Bill Gosper #The first known gun and the first known finite pattern with unbounded growth. #www.conwaylife.com/wiki/index.php?title=Gosper_glider_gun # 9×36- size of this pattern # O …O.0 .00…OO.. ..00 O…O….OO….. 00 . O O…00 00.O.O.00….O.0 O…..O.. O O…O Show transcribed image text #Name: Gosper glider gun #Author: Bill Gosper #The first known gun and the first known finite pattern with unbounded growth. #www.conwaylife.com/wiki/index.php?title=Gosper_glider_gun # 9×36- size of this pattern # O …O.0 .00…OO.. ..00 O…O….OO….. 00 . O O…00 00.O.O.00….O.0 O…..O.. O O…O

Expert Answer


Answer to Write a program that implements the Game of Life cellular automata system invented by John Conway. 1. Create two game gr… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *