monty_hall_game package¶
monty_hall_game.game_warnings module¶
monty_hall_game.monty_hall_game module¶
- class monty_hall_game.monty_hall_game.MontyHallGame[source]¶
Bases:
object
Instantiates a new Monty Hall Game object.
Example usage:
game = MontyHallGame() game.select_door(1) game.let_host_open_door() to_open = random.choice(game.available_doors()) game.select_door(to_open) won = game.open_door()
- let_host_open_door()[source]¶
When this function is called, the host will open a door that contains no price.
- Returns:
The newly opened door number as an int.
- open_door()[source]¶
Opens the door selected by the player
- Returns:
True
if the player has won,False
otherwise.
- select_door(door)[source]¶
Use this function to let the play select a door. This function
should be called twice: Once at the beginning of the game for the initial door choice. And once after calling
MontyHallGame.let_host_open_door()
.- Parameters:
door (int) – The door to be selected. Valid values: [1, 2, 3]
- static statistics()[source]¶
Returns statistics about the winning chances of the “change door” and “do not change door” strategies of all games played.
- stats = {'changed': {'lost': 0, 'won': 0}, 'not_changed': {'lost': 0, 'won': 0}}¶