almost done with my class!

closed account (1y7j1hU5)
Please help me finish my class! Thank you!

Assignment 15.1 [95 points]

This is part 2 of a two part assignment. Your score on this assignment will take into consideration your work on both the previous assignment and this assignment.

Your task is to write a program that plays the game of life. This game is a computer simulation of the life and death events in a population of single-cell organisms. Each position in a two-dimensional grid (Petri dish) can support one cell. The program determines whether each position will be able to support life in the next generation.

The grid of cells is represented by a boolMatrix object. In other words, you are writing a program that USES the boolMatrix class. No changes should be made to boolmatrix.h or boolmatrix.cpp! The starting grid is generation 0 and is read from a supplied input file. Most positions in the grid have 8 neighbors like the center square in a tic-tac-toe game. The four corner positions have only 3 neighbors each. The remaining positions around the edge of the grid have 5 neighbors each. The rules for the state of each position in the next generation of the grid 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. This point is critical to the correct result.
The following three webpages are also available: the data file, the correct output, and the output including intermediate generations. The last webpage is available to help you debug your code.

The data file supplies the data for generation 0. Each line of data gives a pair of coordinates (row# column#) for a living cell in the original grid. Assume that every number in the text file is between 0 and 19. All other grid positions are empty. Please name your file "life.txt".

After your program has created the boolMatrix object that represents generation 0, your program must allow life to proceed for the number of generations specified by the user. Start with five generations. Your program should then display a grid on the screen to show the final results. Use a star (*) to represent a live cell and a space to represent a dead cell. After the grid, display the following statistical information:

The number of living cells in the entire board.
The number of living cells in row 10.
The number of living cells in column 10.
Additional Requirements

Make sure that your output matches the correct output exactly.

To repeat, this program must use the boolMatrix class to represent the grid, rather than declaring its own arrays. You must not use any arrays in your client program.

In this program, a minimum of four functions is required in addition to main(). In my solution there are five functions besides main(). Remember our discussions about stepwise refinement, value-returning vs. void functions, and value parameters vs. reference parameters.

Be sure to document this program thoroughly, as always.

The output that you provide with your submission should show generation 5 for a 20 by 20 grid. And also generation 8 for a grid of 21 rows and 22 columns. The change in grid size should be accomplished by changing only the two named constants in the specification file.

Hints about reading input files:

I suggest that you copy the text from the input file webpage(s) and paste it into a file that you have created using your IDE. The files you create when you type in your IDE are always text files (even if they don't end with .txt). If you're using Windows, you could also use Notepad, but there's no reason to open another application when you are already working in your IDE. I strongly suggest that you don't use TextEdit (Mac) or Word, because these do not store files as text files by default.

Where to save your input file so that your IDE can find it:

In Visual C++, right click on the name of the project in the solution explorer. It appears in bold there. Unless you chose a different name for the project, it will be ConsoleApplication1. From the drop-down menu, choose "show folder in windows explorer". The folder that opens up will be the correct place to save your file.

In Xcode, while on the project navigator tab (looks like a folder) you'll see a yellow folder called products. click the expansion triangle next to it and your project executable should show up. right click it and choose show in finder. The folder it's in pops up and you can add your input file.

Here is a tutorial video created by a former student about creating and placing input files in the right spot for Xcode to find them. It's an alternate method. I would suggest watching this video only if the suggestion above doesn't seem to be working for you. In order for these instructions to work, you must have executed a program in your project at least once. Otherwise the folder named "debug" that the video refers to will not exist.

Extensions are part of the file name. If you want to count the words in a file named "myfile.txt", typing "myfile" or "myfile.cpp" won't work.

For Windows users, before you start this assignment, I suggest that you make sure that Windows is showing you the complete file name of your files, including the extensions. Windows hides this from you by default. In Windows 7 and 8 the procedure is as follows:

Choose "control panel" from the start menu
Choose "Folder Options" from the list of control panel items. In Windows 8 you may have to type "Folder Options" into the control panel search bar.
Choose the "view" tab from the Folder Options window
Find the checkbox that says "Hide extensions for known file types".
Uncheck that checkbox.
I've received two different suggestions from student about how to do this in Windows 10. One student says that the procedure is exactly the same as that outlined above, except that the "Folder Options" window is now the "File Explorer Options" window. The other student says this: go to file explorer and click "View" on the toolbar, then go to "Options" on the furthest right, click on the drop down arrow and choose "Change folder and search options". Click "View" on the top and uncheck "Hide extensions for known file types".

Please let me know if you find that this doesn't work. Also let me know if you think that one of the two Windows 10 options is clearly better.

Submit Your Work

Name your file a15.cpp. Execute your program and paste the output into the bottom of the file, making it into a comment. You will submit this file along with your boolmatrix.h and boolmatrix.cpp files. Use the Assignment Submission link to submit the source files. When you submit your assignment there will be a text field in which you can add a note to me (called a "comment", but don't confuse it with a C++ comment). In this "comments" section of the submission page let me know whether the class works as required.
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/219811/
Topic archived. No new replies allowed.