Due dates:

The Monty Hall Problem

In this assignment, you will implement a simulation of the game show Let's Make A Deal. In particular, you will implement a simulation which allows the user to try out strategies for the Monty Hall Problem.

In the game, the contestant would be shown a stage with three closed doors:

Milestone 1

In Milestone 1, the first of two milestones, you will simulate a single "round" in which

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

Which door would you like to pick? (1-3) 3
Monty shows you a goat behind door number 2
Which door would you like to pick now? (1-3) 1
You won the car!

Another example run (user input in bold):

Which door would you like to pick? (1-3) 2
Monty shows you a goat behind door number 1
Which door would you like to pick now? (1-3) 3
You got a goat, sorry. The car was behind door 2

Milestone 2

In this milestone you will allow the user to play repeated games. After each game, your program should prompt the to enter 1 to continue and 0 quit.

When the user quits, the program should print a summary of how many games were played, how many games the player won, and what percentage of games the player won (to two decimal places.)

Example run showing 3 games (user input in bold):

Which door would you like to pick? (1-3) 1
Monty shows you a goat behind door number 2
Which door would you like to pick now? (1-3) 3
You won the car!
Another game? (1=yes, 0=no) 1
Which door would you like to pick? (1-3) 2
Monty shows you a goat behind door number 3
Which door would you like to pick now? (1-3) 1
You won the car!
Another game? (1=yes, 0=no) 1
Which door would you like to pick? (1-3) 3
Monty shows you a goat behind door number 2
Which door would you like to pick now? (1-3) 1
You got a goat, sorry. The car was behind door 3
Another game? (1=yes, 0=no) 0
You played 3 games
You won 2 games
You won 66.67% of the games

Tasks for milestone 2

Milestone 2 consists of two tasks.

Task 1: Modify the program to allow the player to play multiple times as described above.

You will need to use a loop to allow the game to be repeated. Make sure that statements in your loop are properly indented.

Task 2: Using your program perform experiments to test two different strategies for playing the game:

  1. After Monty reveals the goat, stick with your original choice of door
  2. After Monty reveals the goat, switch doors to whichever door Monty did not reveal

For each strategy, play the game 10 times. What percentage of games did you win each time?

Using Notepad++, create an empty document and write a brief summary of your findings. Save it as a file called experiment.txt in your CS101_Assign02 folder. In the report, indicate what percentage of games you won using each strategy. If one strategy seems to be better, state which one.

Hints

You can allow your program to generate random integer values as follows.

Grading

Milestone 1

Your grade for milestone 1 will be determined as follows:

Milestone 2

Your grade for milestone 2 will be determined as follows:

Submitting

To submit your work, make sure your MontyHall.cpp file is saved, and in the Cygwin window type one of the following commands (depending on whether you are submitting Milestone 1 or Milestone 2).

For Milestone 1:

make submit_ms1

File Milestone 2:

make submit_ms2

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.

If the make commands above do not work, you can submit using the web interface (see the link for details).

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 assign02_ms1 (milestone 1) or assign02_ms2 (milestone 2), 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).