Turn in a file named montyhall.py that uses pygame to recreate the Monty Hall problem, a probability puzzle based on the game show Let's Make a Deal. In the game the contestant is presented with three doors and given the chance to try and pick the one door with a prize behind it. After the contestant chooses one door the host would open one of the remaining two doors to show nothing behind it. Now the contestant is given the chance to stay with the first door they chose or to switch and pick the remaining door. If the contestant chooses the door with the prize behind it then they win!

The generic structure of the game is as follows:

When you create the game you must create three door objects on the screen. You should take advantage of an existing Door class we've provided for you to use in the game. The methods of the door class are listed below. The prize behind each door defaults to a goat when it is created. Every time the game is played you should choose a random door to be the winner. You may do this by using the doors set_winner() method.

Along with the doors you should create a font object of size 25 that renders black, antialiased text that is blitted near the top left corner of the screen (10 pixels from the left edge and 5 pixels from the top) every time the graphics are updated. The text will tell the player what to do as they progress through the game.

To track the user's input within the game your program should wait for MOUSEBUTTONDOWN event types. Your program should take advantage of mouse.get_pos() to retrieve the x and y coordinates of mouse clicks so you may convert them to pygame Rect objects and take advantages of each doors .select(click) method.

The program should contain two booleans used to keep track of how far along the player is in the game. For instance, if a player has not chosen a door and the game has not revealed one door as a loser then you now the player is at the beginning of the game and must choose a door. Use these booleans to differentiate what code should be executed whenever pygame detects a mouse click.

Door class

set_image(String image_path) sets the door graphic to the given image path.

set_winner(boolean winner) sets the doors internal is_winner to boolean.

is_winner() returns boolean self.winner.

select(Rect click) Accepts a click as Rect object and checks to see if the click hit the door. If the click intersects with the door then it changes the internal boolean door.selected to True, sets door.image to "chosen.jpg" and returns True. If the click does not intersect with the door this returns False.

is_selected() returns boolean self.selected.

open() changes door sprite image to gold.jpg or goat.jpg depending on whether door.winner is True.

Stylistic Guidelines

Expected Output

The final screen should display either "you win!" or "you got the goat!" depending on whether the player chose the door with the prize at the end.

or