Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As stated in directions, must use at least one of the iomanip.h functionalities shown above. Not specified which, thanks! The Game of Life, invented by

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

As stated in directions, must use at least one of the iomanip.h functionalities shown above. Not specified which, thanks!

The Game of Life, invented by the mathematician John H. Conway, is intended to model life in a society of organisms. Consider a rectangular array of cells, each of which may contain an organism. If the array is viewed as extending indefinitely in both directions, then each cell has eight neighbors, the eight cells surrounding it. In each generation, births and deaths occur according to the following rules An organism is born in any empty cell having exactly three neighbors An organism dies from isolation if it has fewer than two neighbors An organism dies from overcrowding if it has more than three neighbors. * All other organisms survive To illustrate, the following shows the first five generations of a particular configuration of organisms 0 0 0 0 0 0 0 0 0 0 Specific Instructions Write a modular program to simulate the Game of Life and investigate the patterns produced by various initial configurations. Some configurations die off rather rapidly; others repeat after a certain number of generations; others change shape and size and may move across the array; and still others may produce 'gliders' that detach themselves from the society and sail off into space! Since the game requires an array of cells that continually expands/shrinks, you would want to use multi-dimensional arrays and dynamic memory allocation. Your program should consist of at least two modules. One module will implement a class to represent Game of Life. Following good object-oriented programming practices, keep the data members private. Accessor functions should be declared to set and get the private data if needed. A Game ofLife object should be able to initialize itselfusing input from a file, evolve through the different generations and display each generation! Write a test program that illustrates the use of your Game of life class and representative output (at least 5 generations) for every dataset in the input file that will be provided. Additionally, the output should be displayed in format that is easy to understand and you have to make use of at least one of the functionalities from the header file ion annh>. Overloading of input and output operators is required. Include all the source code (well documented) and input/output files/screenshots. Issued: Feb 13, 2019 Due: Feb 25, 2019 with demo on Feb 27 CS 501 Assignment 2 Spring 2019 University of Bridgeport p est sretin shnad nets t mia Sample Input file: 4 5 /indicates number of rows and columns 1 1 //list of all the positions of organisms 1 2 1 3 -1 lend of current dataset, there can be more datasets in a larger input file Corresponding ouiput nle: Generation 1: #xxx# ##x## Generation 2: ##x## #xxx# #xxx# Generation 3: #xxx# #x#x# ##x## Generation 4: ##x## ##x## #x#x# ##x## ##x## Generation 5: #xxx# Definitions resetiosflags setiosflags setbase setfill setprecision setw get_money (C++11) (function template) put_ money (unction template get_time (c++11) clears the specified ios_base flags (function) sets the specified ios_base flags (function) changes the base used for integer I/C (function) changes the fill character (function template) changes floating-point precision (function) changes the width of the next input/output field (function) parses a monetary value formats and outputs a monetary value parses a date/time value of specified format (function template) formats and outputs a date/time value according to the specified format put time(C++11) (function template) inserts and extracts quoted strings with embedded spaces (function template) quoted (C++14) The Game of Life, invented by the mathematician John H. Conway, is intended to model life in a society of organisms. Consider a rectangular array of cells, each of which may contain an organism. If the array is viewed as extending indefinitely in both directions, then each cell has eight neighbors, the eight cells surrounding it. In each generation, births and deaths occur according to the following rules An organism is born in any empty cell having exactly three neighbors An organism dies from isolation if it has fewer than two neighbors An organism dies from overcrowding if it has more than three neighbors. * All other organisms survive To illustrate, the following shows the first five generations of a particular configuration of organisms 0 0 0 0 0 0 0 0 0 0 Specific Instructions Write a modular program to simulate the Game of Life and investigate the patterns produced by various initial configurations. Some configurations die off rather rapidly; others repeat after a certain number of generations; others change shape and size and may move across the array; and still others may produce 'gliders' that detach themselves from the society and sail off into space! Since the game requires an array of cells that continually expands/shrinks, you would want to use multi-dimensional arrays and dynamic memory allocation. Your program should consist of at least two modules. One module will implement a class to represent Game of Life. Following good object-oriented programming practices, keep the data members private. Accessor functions should be declared to set and get the private data if needed. A Game ofLife object should be able to initialize itselfusing input from a file, evolve through the different generations and display each generation! Write a test program that illustrates the use of your Game of life class and representative output (at least 5 generations) for every dataset in the input file that will be provided. Additionally, the output should be displayed in format that is easy to understand and you have to make use of at least one of the functionalities from the header file ion annh>. Overloading of input and output operators is required. Include all the source code (well documented) and input/output files/screenshots. Issued: Feb 13, 2019 Due: Feb 25, 2019 with demo on Feb 27 CS 501 Assignment 2 Spring 2019 University of Bridgeport p est sretin shnad nets t mia Sample Input file: 4 5 /indicates number of rows and columns 1 1 //list of all the positions of organisms 1 2 1 3 -1 lend of current dataset, there can be more datasets in a larger input file Corresponding ouiput nle: Generation 1: #xxx# ##x## Generation 2: ##x## #xxx# #xxx# Generation 3: #xxx# #x#x# ##x## Generation 4: ##x## ##x## #x#x# ##x## ##x## Generation 5: #xxx# Definitions resetiosflags setiosflags setbase setfill setprecision setw get_money (C++11) (function template) put_ money (unction template get_time (c++11) clears the specified ios_base flags (function) sets the specified ios_base flags (function) changes the base used for integer I/C (function) changes the fill character (function template) changes floating-point precision (function) changes the width of the next input/output field (function) parses a monetary value formats and outputs a monetary value parses a date/time value of specified format (function template) formats and outputs a date/time value according to the specified format put time(C++11) (function template) inserts and extracts quoted strings with embedded spaces (function template) quoted (C++14)

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 Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago