Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that implements the Game of Life cellular automata system invented by John Conway 1. Create two game grids of size at least

image text in transcribed

Write a program that implements the Game of Life cellular automata system invented by John Conway 1. Create two game grids of size at least 50x50. These grid cells can be either Boolean or integer. In the following, I'll refer to these as gridOne and gridTwo. 2. Set al cells in both grids to false. 3. Start by initializing gridOne. Allow the user to specify two different ways of initializing the grid: 1) by specifying a pattern file to read or 2) by initializing some percentage of the grid cells A sample life pattern file is included in the homework folder on eLearning. It is named GosperGliderGun.txt. Use this file to start, but you can download other files from the web and use them for your simulations as well. But set the default file name to open to "GosperGliderGun.txt Using gridOne, calculate the conditions for all cells for the next generation of the game, and store the results in gridTwo. Flip back and forth from gridOne to gridTwo, using one grid to calculate the other. Print the next generation grid at each turn, just as we did in Wolfram's one-dimensional cellular automata. In other words, if you're examining gridOne, use gridTwo to store the next state of the world; and if you're examining gridTwo, store the next state in gridOne. Flip back and forth this way, and print out the appropriate grid at each step. NOTE: Be sure to clear the screen before printing out a grid. In Windows, you can use system("CLS") Once the simulation begins, the user might want to pause the game to inspect the state of the cells Add a pause feature just as we did in the Snake Game, using_kbhit() from conio.h. Pause when the user hits one key and resume when the user hits another. 4. 5. 6. But if the user hits the "s" key, stop the game and write the current grid to a file named "LifeGrid- and 'O notation as used in the input pattern file. You can then quit the Final.txt". Use the same game Make sure you are handling your edge cells properly, but don't wrap the world around. Just let edge cells die a lonely death if they want to 7. 8. When printing a grid on the user's screen, useor a space for dead cells. For live cells, use 'O or Once things are working, try using larger and larger grid sizes (or even smaller, if you want) Also, try finding other Life Patterns on the web and running them with your program. And be sure to use random initializations at some points and play around with different percentages of Write a program that implements the Game of Life cellular automata system invented by John Conway 1. Create two game grids of size at least 50x50. These grid cells can be either Boolean or integer. In the following, I'll refer to these as gridOne and gridTwo. 2. Set al cells in both grids to false. 3. Start by initializing gridOne. Allow the user to specify two different ways of initializing the grid: 1) by specifying a pattern file to read or 2) by initializing some percentage of the grid cells A sample life pattern file is included in the homework folder on eLearning. It is named GosperGliderGun.txt. Use this file to start, but you can download other files from the web and use them for your simulations as well. But set the default file name to open to "GosperGliderGun.txt Using gridOne, calculate the conditions for all cells for the next generation of the game, and store the results in gridTwo. Flip back and forth from gridOne to gridTwo, using one grid to calculate the other. Print the next generation grid at each turn, just as we did in Wolfram's one-dimensional cellular automata. In other words, if you're examining gridOne, use gridTwo to store the next state of the world; and if you're examining gridTwo, store the next state in gridOne. Flip back and forth this way, and print out the appropriate grid at each step. NOTE: Be sure to clear the screen before printing out a grid. In Windows, you can use system("CLS") Once the simulation begins, the user might want to pause the game to inspect the state of the cells Add a pause feature just as we did in the Snake Game, using_kbhit() from conio.h. Pause when the user hits one key and resume when the user hits another. 4. 5. 6. But if the user hits the "s" key, stop the game and write the current grid to a file named "LifeGrid- and 'O notation as used in the input pattern file. You can then quit the Final.txt". Use the same game Make sure you are handling your edge cells properly, but don't wrap the world around. Just let edge cells die a lonely death if they want to 7. 8. When printing a grid on the user's screen, useor a space for dead cells. For live cells, use 'O or Once things are working, try using larger and larger grid sizes (or even smaller, if you want) Also, try finding other Life Patterns on the web and running them with your program. And be sure to use random initializations at some points and play around with different percentages of

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions