Milestone 1 due Tuesday, June 17th

Milestone 2 due Tuesday, June 24th

Getting Started

Start by downloading CS101_Assign03.zip, saving it in the directory H:\CS101.

There are two milestones.

Milestone 1

In the first milestone, you will begin writing a program to simulate falling dominos. You will add code to the file FallingDominoes.cpp.

Your program should allow the user to determine the initial configuration of the "playing field" consisting of 10 positions. Once the configuration has been entered by the user, the program should print a line of text which is a "picture" of the configuration.

Here is an example run (user input in bold):

Enter the initial configuration:
Position 1 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 2 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 3 (0=empty, 1=upright, 2=tipping, 3=horizontal): 0
Position 4 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 5 (0=empty, 1=upright, 2=tipping, 3=horizontal): 2
Position 6 (0=empty, 1=upright, 2=tipping, 3=horizontal): 3
Position 7 (0=empty, 1=upright, 2=tipping, 3=horizontal): 0
Position 8 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 9 (0=empty, 1=upright, 2=tipping, 3=horizontal): 2
Position 10 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1

Initial configuration:
|| |/_ |/|

When printing out the state of the playing field, each upright domino should be represented by a "|" character, each tipping domino by "/", each horizontal domino by "_", and each empty position by a blank space.

Hints

Use an array of integer values to represent the playing field. The element at position 0 is position 1, the element at index 1 is position 2, etc. The value of each element determines what is at that position: 0 for an empty space, 1 for an upright domino, 2 for a tipping domino, 3 for a horizontal domino.

Each iteration of the loop that prints the playing field should print a character representing one position. Print "|" if the position has an upright domino, "/" if the position has a tipping domino, etc.

Grading

Out of 50 points:

Milestone 2

In this milestone, you will allow the user to simulate what happens when the first domino is pushed over: in other words, the simulation begins by changing the domino at position 1 from upright to tipping (if it was initially upright).

After the first domino has been tipped, the simulation should run for exactly 10 time steps.

Here is an example run (user input in bold):

Position 1 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 2 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 3 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 4 (0=empty, 1=upright, 2=tipping, 3=horizontal): 0
Position 5 (0=empty, 1=upright, 2=tipping, 3=horizontal): 2
Position 6 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 7 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 8 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1
Position 9 (0=empty, 1=upright, 2=tipping, 3=horizontal): 0
Position 10 (0=empty, 1=upright, 2=tipping, 3=horizontal): 1

Tipping over domino 0:
/|| /||| |

Time step 1:
_/| _/|| |
Time step 2:
__/ __/| |
Time step 3:
___ ___/ |
Time step 4:
___ ____ |
Time step 5:
___ ____ |
Time step 6:
___ ____ |
Time step 7:
___ ____ |
Time step 8:
___ ____ |
Time step 9:
___ ____ |
Time step 10:
___ ____ |

The rules of the simulation are as follows:

Hints

Each time step should be implemented as two for loops:

You should use a value for "ready to tip" positions that is distinct from the values that represent empty, upright, tipping, and horizontal.

Use a third for loop to print out the configuration of the playing field after the simulation of the timestep has completed.

Grading

Out of 100 points:

Submitting

To submit your work, make sure your FallingDominos.cpp file is saved, and in the Cygwin window type the command

make submit_ms1

to submit Milestone 1, or

make submit_ms2

to submit Milestone 2.

Enter your Marmoset username and password (which you should have received by email.) Note that your password will not be echoed to the screen. Make sure that after you enter your username and password, you see a message indicating that the submission was successful.

Important: Make sure that you check the file(s) you submitted to ensure that they are correct. Log into the server using the following URL (also linked off the course homepage):

https://cs.ycp.edu/marmoset/

You should see a list of labs and assignments. In the row for assign03_ms1 or assign03_ms2, click the link labeled view. You will see a list of your submissions. Download the most recent one (which should be listed first). Verify that it contains the correct files.

You are responsible for making sure that your submission contains the correct file(s).