C:\> Rostislav Persion's Projects

.:: Monty Hall Paradox Simulator ::.
Python Monty Hall Simulator


This is a Pytohn program that simulates the famous Monty Hall Paradox.

You are on a game show. There are three doors. Behind two of them are two goats, and behind one of the doors is a car. You are to choose one door. Then the host opens one of the two other doors which has a goat behind it. You are then supposed to either open the first door that you selected, or you can open the 3rd remaining door.

Turns out that changing your choice will increase the probability of you selecting the car vs staying with the door you selected first.

RESULTS:

TRIAL #1FIRST DOOR: 0 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #2FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #3FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #4FIRST DOOR: 2 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #5FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #6FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #7FIRST DOOR: 0 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #8FIRST DOOR: 1 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #9FIRST DOOR: 2 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #10FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #11FIRST DOOR: 0 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #12FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #13FIRST DOOR: 0 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #14FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #15FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #16FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #17FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #18FIRST DOOR: 2 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #19FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #20FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #21FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #22FIRST DOOR: 1 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #23FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #24FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #25FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #26FIRST DOOR: 0 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #27FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #28FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #29FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #30FIRST DOOR: 2 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #31FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #32FIRST DOOR: 2 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #33FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #34FIRST DOOR: 0 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #35FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #36FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #37FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #38FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #39FIRST DOOR: 0 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #40FIRST DOOR: 1 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #41FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #42FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #43FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #44FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #45FIRST DOOR: 0 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #46FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #47FIRST DOOR: 2 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #48FIRST DOOR: 1 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #49FIRST DOOR: 2 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #50FIRST DOOR: 2 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #51FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #52FIRST DOOR: 2 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #53FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #54FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #55FIRST DOOR: 0 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #56FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #57FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #58FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #59FIRST DOOR: 0 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #60FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #61FIRST DOOR: 2 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #62FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #63FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #64FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #65FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #66FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #67FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #68FIRST DOOR: 1 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #69FIRST DOOR: 2 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #70FIRST DOOR: 2 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #71FIRST DOOR: 2 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #72FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #73FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #74FIRST DOOR: 2 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #75FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #76FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #77FIRST DOOR: 1 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #78FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #79FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #80FIRST DOOR: 0 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #81FIRST DOOR: 0 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #82FIRST DOOR: 2 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #83FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #84FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #85FIRST DOOR: 0 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #86FIRST DOOR: 2 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #87FIRST DOOR: 2 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #88FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #89FIRST DOOR: 2 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #90FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #91FIRST DOOR: 1 = GOATGOAT DOOR: 0 = GOATOTHER DOOR: 2 = CARRESULT: YOU WIN!TRIAL #92FIRST DOOR: 1 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 0 = GOATRESULT: YOU LOSE!TRIAL #93FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #94FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #95FIRST DOOR: 0 = GOATGOAT DOOR: 2 = GOATOTHER DOOR: 1 = CARRESULT: YOU WIN!TRIAL #96FIRST DOOR: 2 = GOATGOAT DOOR: 1 = GOATOTHER DOOR: 0 = CARRESULT: YOU WIN!TRIAL #97FIRST DOOR: 0 = CARGOAT DOOR: 1 = GOATOTHER DOOR: 2 = GOATRESULT: YOU LOSE!TRIAL #98FIRST DOOR: 2 = CARGOAT DOOR: 0 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!TRIAL #99FIRST DOOR: 0 = CARGOAT DOOR: 2 = GOATOTHER DOOR: 1 = GOATRESULT: YOU LOSE!65 WINS AND 34 LOSSES.


SOFTWARE WRITTEN IN PYTOHN
import random#keep track of wins and losseswins = 0losses = 0for TrialNum in range(1,100):    Doors = ["car","goat","goat"]    random.shuffle(Doors)    #pick first door    FirstDoor = random.randint(0, 2)    #pick goat door from remaining two    GoatDoor = FirstDoor    while GoatDoor == FirstDoor or not Doors[GoatDoor] == "goat":        GoatDoor = random.randint(0, 2)    #pick the door thats not the first or second    OtherDoor = FirstDoor    while OtherDoor == FirstDoor or OtherDoor == GoatDoor:        OtherDoor = random.randint(0, 2)    #show statistics    print("TRIAL #" + str(TrialNum))    print("FIRST DOOR: " + str(FirstDoor) + " = " + Doors[FirstDoor].upper())    print("GOAT DOOR: " + str(GoatDoor) + " = "  + Doors[GoatDoor].upper())    print("OTHER DOOR: " + str(OtherDoor) + " = " +  Doors[OtherDoor].upper())        if Doors[OtherDoor] == "car":        wins += 1        print("RESULT: YOU WIN!")    else:        losses += 1        print("RESULT: YOU LOSE!")    print("")print(str(wins) + " WINS AND " + str(losses) + " LOSSES.")


VERSION 2:

import random#keep track of wins and losseswins = 0losses = 0for TrialNum in range(1,100):    Doors = ["car","goat","goat"]    random.shuffle(Doors)    #pick first door    FirstDoor = random.randint(0, 2)    #pick goat door from remaining two    for i in range(0,3):        if i != FirstDoor and Doors[i] == "goat":            GoatDoor = i            break    #pick the door thats not the first or second    for i in range(0,3):        if i != FirstDoor and i != GoatDoor:            OtherDoor = i            break    #show statistics    print("TRIAL #" + str(TrialNum))    print("FIRST DOOR: " + str(FirstDoor) + " = " + Doors[FirstDoor].upper())    print("GOAT DOOR: " + str(GoatDoor) + " = "  + Doors[GoatDoor].upper())    print("OTHER DOOR: " + str(OtherDoor) + " = " +  Doors[OtherDoor].upper())        if Doors[OtherDoor] == "car":        wins += 1        print("RESULT: YOU WIN!")    else:        losses += 1        print("RESULT: YOU LOSE!")    print("")print(str(wins) + " WINS AND " + str(losses) + " LOSSES.")


FINAL ATTEMPT, MORE EFFICIENT:

import random#keep track of wins and losseswins = 0losses = 0for TrialNum in range(1,100):    Doors = ["car","goat","goat"]    random.shuffle(Doors)        FirstDoor = Doors.pop(0)    Doors.remove("goat")    GoatDoor = "goat"    OtherDoor = Doors[0]    #show statistics    print("TRIAL #" + str(TrialNum))    print("FIRST DOOR: " + FirstDoor)    print("GOAT DOOR: " + GoatDoor)    print("OTHER DOOR: " + OtherDoor)        if OtherDoor == "car":        wins += 1        print("RESULT: YOU WIN!")    else:        losses += 1        print("RESULT: YOU LOSE!")    print("")print(str(wins) + " WINS AND " + str(losses) + " LOSSES.")