Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//Please, help me out with this problem... This Problem has to be done and C++ and strictly follow the instructions. The contents of the file

//Please, help me out with this problem... This Problem has to be done and C++ and strictly follow the instructions. The contents of the file "life.txt" has been provided below (opened through textedit, and copy-pasted)..I am also providing the expected output of this problem. Thanks in advance.. image text in transcribed Contents of the file "life.txt" : -*------------------ --*----------------- ***----------------- -------------------- -------------------- -------------***---- -------------------- --------------------

Expected output of this problem : Initial world * * *** *** =========================== Generation: 1 * * ** * * * * ==================== Generation: 2 * * * ** *** ==================== Generation: 3 * ** ** * * * ==================== Generation: 4 * * *** *** ==================== Generation: 5 * * ** * * * * ==================== Generation: 6 * * * ** *** ==================== Generation: 7 * ** ** * * * ==================== Generation: 8 * * *** *** ==================== Generation: 9 * * ** * * * * ==================== Generation: 10 * * * ** *** ====================

Implement Conway's Game of life . The rules of life sav: o A living cell with two or three neighboring living cells survives into the next generation. A living cell with fewer than two living neighbors dies of loneliness and a living cell with more than three living neighbors will die from overcrowding o Each empty/dead cell that has exactly three living neighbors--no more, no fewer- comes to life in the next generation. Input: o Get the initial state from a file, named "life.txt" in the current working directory o Each row will have dashes for dead cells and asterisks for live ones o To be nice, I will make all lines the same length. Output to standard output (i.e. the screen) o Display the original state of the world, as read in from the file and 10 additional generations. o In each generation, each row will have spaces and asterisks. (spaces look nicer than dashes) - Spaces represent empty/dead cells Asterisks represent occupied/living cells Suggestion: For your internal representation, create an extra row on the top and bottom as well as an extra column to the right and the left of the actual data. Mark the extra cells as dead. This will simplify your code, as you won't need special checks for "boundary" cells Sample input and output for the program are attached Good programming style o Naming o Use of functions o Length of lines and functions o Comments are not required for labs except be sure there is a comment at the top of the file identifying the author (you, hopefully), the name of the program file, and a [very] brief description of the program Note that all of your submissions for the semester should have such a comment at the beginning of each code file

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions