Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project#5 - Two-dimensional array operations: Game of Life program** The game of life is a computer simulation of the life and death events of a

Project#5 - Two-dimensional array operations: Game of Life program**

The game of life is a computer simulation of the life and death events of a population of organisms. This program will determine the life, death, and survival of bacteria from one generation to the next, assuming the starting grid of bacteria is generation zero (0). Each cell has a total of up to 8 neighbors, including the 4 immediately adjacent cells and the 4 diagonal cells. The rules for the creation of each cell in the next generation are as follows:

If the cell is currently empty:

If the cell has exactly three living neighbors, it will come to life in the next generation.

If the cell has any other number of living neighbors, it will remain empty.

If the cell is currently living:

If the cell has one or zero living neighbors, it will die of loneliness in the next generation.

If the cell has four or more living neighbors, it will die of overcrowding in the next generation.

If the cell has two or three neighbors, it will remain living.

All births and deaths occur simultaneously (make sure you don't get this one wrong!).

First check the following html links that provide context and visual content of data related to this project:initial grid data, grid output including intermediate generations andoriginal grid and final correct grid output.

Your task is to write a program that plays the game of life. The size of the grid will be a 20 x 20 square. Your solution must use a 20 X 20 two-dimensional array. Don't declare a bigger array! It is permissible, of course, to use a second array of the same size if you find it convenient or helpful to do so.

A "Game_of_life" class (ADT) set-up and implementation is possible but is not required. DO NOT use pointers or vectors for this project.

The original grid of bacteria will be supplied to your program from a text file called bacteria.txt. The text file will contain one line of data for each bacteria in the original grid. Each line will consist of a pair of numbers, separated by a space. The first number will indicate the row index or location of the bacteria and the second number will indicate the column index or location of the bacteria. Every number in the text file will be between 0 and 19.

To begin the "game of life" your program must initialize the grid with generation 0 which should now include live cells based on the coordinates provided in the bacteria.txt file. Next your program must use the criteria provided above and allow life to proceed for 5 generations. Finally, your program should display the life forms for the fifth generation on the screen, using asterisks (*) to represent live bacteria on a grid, along with the following statistical information:

The total number of living bacteria cells in row index 10.

The number of dead bacteria cells in row index 10.

The number of living bacteria cells in column index 10.

The number of dead bacteria cells in column index 10.

The number of living bacteria cells in the entire board.

The number of dead bacteria cells in the entire board.

*note ...row 10 and column 10 refers to the actual row and column indexes in the 20 x 20 two-dimensional array

Please make sure that you use the following input file bacteria.txt and make sure your output matches the original grid and final correct grid output exactly. You may use the following visual grid output including intermediate generations as you code and test your grid data and output. Note: Do not worry if your compiled version of grid output pasted in the text box below appears a bit skewed in the confirmation email. I will be compiling your submitted source code and so should see the correctly formatted grid.

Your instructor will provide a few "game of life" start-up hints during the week 16-17 lecture/lab sessions so be checking the class resources page for recordings or any resources provided.

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago