Anonymous user
Monty Hall problem: Difference between revisions
→{{header|HicEst}}
(→{{header|HicEst}}: Not sufficiently ''simulating'' the steps in the actual game) |
|||
Line 730:
=={{header|HicEst}}==
<lang hicest>REAL :: ndoors=3, doors(ndoors), plays=1E4
switchWins = 0
Line 737 ⟶ 738:
DO play = 1, plays
doors = 0 ! clear the doors
doors(winner) = 1
guess = 1 + INT(RAN(doors)) ! player chooses his door
switchWins = switchWins + (guessed_cars_door /= car_is_behind_door)▼
IF( guess == winner ) THEN ! Monty decides which door to open:
show = 1 + INT(RAN(2)) ! select 1st or 2nd goat-door
checked = 0
DO check = 1, ndoors
checked = checked + (doors(check) == 0)
IF(checked == show) open = check
ENDDO
ELSE
open = (1+2+3) - winner - guess
ENDIF
new_guess_if_switch = (1+2+3) - guess - open
stayWins = stayWins + doors(guess) ! count if guess was correct
ENDDO
WRITE(ClipBoard, Name) plays, switchWins, stayWins
<lang hicest>plays=1E3; switchWins=641; stayWins=359;▼
END</lang>
plays=1E4; switchWins=6668; stayWins=3332;▼
<lang hicest>! plays=
! plays=
=={{header|J}}==
|