08-16-2022, 05:01 PM
Here's my sim:
Code: (Select All)
Dim door(1 To 3)
Const Limit = 1000 'number of games to play without switching, and then repeat that number and switch
Randomize Timer
For i = 1 To Limit
Print "Game #"; i
prize = Int(Rnd * 3) + 1 'which door is the prize behind?
Print "Is it behind Door #1, #2, or #3?"
guess = Int(Rnd * 3) + 1 'where is our initial guess
Print "I guess door #"; guess
'here we can waste some time not swapping
If guess = prize Then eliminate = guess + 1: If eliminate > 3 Then eliminate = 1
Print "It's not behind door #"; eliminate; "! Will you swap?"
Print "Nope! I want to keep my choice."
Print "Since you're keeping it, let's see what happens!"
If guess = prize Then
win = win + 1
Print "You win the car!"
Else
lose = lose + 1
Print "Sorry! It was behind door #"; prize
End If
Next
Print "Of "; Limit; "games, you won "; win; "times and lost "; lose; "times by not swapping!"
Sleep
For i = 1 To Limit
Print "Game #"; i
prize = Int(Rnd * 3) + 1 'which door is the prize behind?
Print "Is it behind Door #1, #2, or #3?"
guess = Int(Rnd * 3) + 1 'where is our initial guess
Print "I guess door #"; guess
'here we can waste some time not swapping
If guess = prize Then eliminate = guess + 1: If eliminate > 3 Then eliminate = 1
Print "It's not behind door #"; eliminate; "! Will you swap?"
Print "Nope! I want to keep my choice."
Print "Since you're keeping it, let's see what happens!"
If guess = prize Then
lose2 = lose2 + 1
Print "Sorry! It was behind door #"; eliminate
Else
win2 = win2 + 1
Print "You win the car!"
End If
Next
Print "Of "; Limit; "games, you won "; win2; "times and lost "; lose2; "times by swapping!"
Print
Print "To compare:"
Print "Of "; Limit; "games, you won "; win; "times and lost "; lose; "times by not swapping!"