• -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 get opt 0 . This should be similar to what you did in previous assignments.
2. Use an initial call to f 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 f scanf 0 . 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_populat e ( ) 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 either setting or clearing the corresponding cell in universe B, based off the 3 rules discussed in §2. (c) Swap the universes. Think of universe A as the current 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 0 .
8. Output universe A to the specified file using uv_print 0 . 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.