monty_hall_game package

monty_hall_game.game_warnings module

exception monty_hall_game.game_exceptions.InvalidGameInput(message)[source]

Bases: Exception

This exception should be thrown if invalid input is provided to the game. An example is to finish the game before selecting a door.

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()
available_doors()[source]

Returns a list of doors that are still available for selection

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}}
winning_door()[source]