Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Game of Life is a well- known mathematical game that gives rise to amazingly complex behavior, although it can be specif ied by a

The Game of Life is a well-

known mathematical game that gives rise to amazingly complex

behavior, although it can be specif

ied by a few simple rules. (It is not actually a game in the

traditional sense, with players competing for a win.) Here are the rules. The game is played on a

rectangular board. Each square can be either empty or occupied. At the beginning, you can

specify

empty and occupied cells in some way; then the game runs automatically. In each

generation, the next generation is computed. A new cell is born on an

empty square if it is surrounded by exactly three occupied neighbor

cells. A cell dies of overcrowding if

it is surrounded by four or more

neighbors, and it dies of loneliness if it is surrounded by zero or one

neighbor. A neighbor is an occupant of an adjacent square to the left,

right, top, or bottom or in a diagonal direction. Figure 21 shows a cell

and its neighbor cells.

image text in transcribedimage text in transcribed

The Game of Life The Game of Life is a well-known mathematical game that gives rise to amazingly complex behavior, although it can be specified by a few simple rules. (It is not actually a game in the traditional sense, with players competing for a win.) Here are the rules. The game is played on a rectangular board. Each square can be either empty or occupied. At the beginning, you can specify empty and occupied cells in some way; then the game runs automatically. In each generation, the next generation is computed. A new cell is born on an empty square if it is surrounded by exactly three occupied neighbor cells. A cell dies of overcrowding if it is surrounded by four or more neighbors, and it dies of loneliness if it is surrounded by zero or one neighbor. A neighbor is an occupant of an adjacent square to the left, Figure 21 right, top, or bottom or in a diagonal direction. Figure 21 shows a cell Neighborhood of a Cell and its neighbor cells. Cell Neighbors Generation O Generation1 Generation 2 Generation 3 Generation 4 Figure 22 Glider Many configurations show interesting behavior when subjected to these rules. Figure 22 shows a glider, observed over five generations. After four generations, it is transformed into the identical shape, but located one square to the right and below. One of the more amazing configurations is the glider gun: a complex collection of cells that, after 30 moves, turns back into itself and a glider (see Figure 23). Program the game to eliminate the drudgery of computing successive generations by hand. Use a two-dimensional array to store the rectangular configuration. Write a program that shows successive generations of the game on console (no GUI). Ask the user to specify the original configuration, by typing in a configuration of spaces and o characters. Figure 23 Glider Gun Generation Generation 30 Generation 60 Genration 90 Generation 120 Generation 150

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago