Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

* -o output : Specify the output file to print the final state of the universe to. By default the output should be stdout. 6 Specifics Jehosaphat the mongrel cat Jumped off the roof today Some...

1 answer below »
* -o output : Specify the output file to print the final state of the universe to. By default the output
should be stdout.
6 Specifics
Jehosaphat the mongrel cat
Jumped off the roof today
Some would say he fell but I could tell
He did himself away
—John Prine, Living in the Future
Here are the specifics for your assignment implementation.
1. Parse the command-line options by looping calls to getopt (). This should be similar to what you
did in previous assignments.
2. Use an initial call to £scanf () to read the number of rows and columns of the universe you will be
populating from the specified input.
3. Create two universes using the dimensions that were obtained using fscanf (). Mark the universes
toroidal if the -t option was specified. We will refer to these universes as universe A and universe
B.
4. Populate universe A using uv_populate() with the remainder of the input.
5. Setup the ncurses screen, as show by the example in §4.
6. For each generation up to the set number of generations:
(a) If ncurses isn't silenced by the -s option, clear the screen, display universe A, refresh the
screen, then sleep for 50000 microseconds.
(b) Perform one generation. This means taking a census of each cell in universe A and eithe
setting or clearing the co
esponding cell in universe B, based off the 3 rules discussed in §2.
(c) Swap the universes. Think of universe A as the cu
ent state of the universe and universe B
as the next state of the universe. To update the universe then, we simply have to swap A and
B. Hint: swapping pointers is much like swapping integers.
7. Close the screen with endwin().
8. Output universe A to the specified file using uv_print (). This is what you will be graded on. We
will know if you properly evolved your universe for the set number of generations by comparing
your output to that of the supplied program.
Answered 5 days After Feb 05, 2023

Solution

Pratyush answered on Feb 09 2023
45 Votes
Answers
1.
The things that I have learnt from the assignment are as follow:
- The game of life and the principles of this theory.
- I learnt how we can manage the definitions and declarations in different files, i.e, in .h
files and .c files.
- Linking different files together
- We should use proper coding format and make sure freeing up memory allocated in the
heap, at the end of the program.
- I learnt about command line...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here