The player in this game should change another door after Monty Hall openinga door behaind which there is a goat. Beacuse, if the player persist the former choice, the probability of get a car is 1/3. This is also the probiblity of the player made the right choice in the first time. However, if the player change the choice, the probability of get a car is the same as the probability that the player made a wrong choice at first time, so the probability of get a car is 2/3. Therefore, the player should change the choice after Mony Hall open a ‘goat door’.

if not change, the probality of get a car: run 10000000 simulation tests

n <- 0
for ( i in 1:10000000) {
    door <- c(1,2,3)
    choice <- sample(door,1)
    cardoor <- sample(door,1)
    if (choice == cardoor) {
        n <- n + 1
    }
}
print(n/10000000)
## [1] 0.3332662

if change, the probability of get a car : run 10000000 simulation tests

n <- 0
door <- c(1,2,3)
for ( i in 1:10000000) {
    cardoor <- sample(door,1)
    select <- sample(door,1)
    remove <- ifelse(cardoor==select, 
                    sample(setdiff(door,cardoor),1),
                    setdiff(door,c(cardoor,select)))
    reselect <- setdiff(door,c(select,remove))
    if (cardoor == reselect) {
        n <- n + 1
    }
}
print(n/10000000)
## [1] 0.6665251