Monty Hall problem: Difference between revisions

(→‎{{header|HicEst}}: Not sufficiently ''simulating'' the steps in the actual game)
Line 730:
 
=={{header|HicEst}}==
<lang hicest>REAL :: ndoors=3, doors(ndoors), plays=1E4
{{incorrect|HicEst|You are not sufficiently ''simulating'' the steps in the actual game to get your result. (C.f: [[Talk:Monty_Hall_problem#Is_the_Perl_implementation_correct.3F]]).}}
 
<lang hicest>DLG(NameEdit = plays, DNum=1, Button='Go')
 
switchWins = 0
Line 737 ⟶ 738:
 
DO play = 1, plays
doors = 0 ! clear the doors
car_is_behind_door = 1 + INT(RAN(3))
guessed_cars_door winner = 1 + INT(RAN(3ndoors)) ! door that has the prize
doors(winner) = 1
stayWins = stayWins + (guessed_cars_door == car_is_behind_door)
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
switchWins = switchWins + doors(guessed_cars_door /= car_is_behind_doornew_guess_if_switch)
ENDDO
 
WRITE(ClipBoard, Name) plays, switchWins, stayWins</lang>
 
<lang hicest>plays=1E3; switchWins=641; stayWins=359;
END</lang>
plays=1E4; switchWins=6668; stayWins=3332;
<lang hicest>! plays=1E51E3; switchWins=66859695; stayWins=33141305;
! plays=1E61E4; switchWins=6664036673; stayWins=3335973327;</lang>
<lang! hicest>plays=1E31E5; switchWins=64166811; stayWins=35933189;
! plays=1E41E6; switchWins=6668667167; stayWins=3332332833;</lang>
 
=={{header|J}}==
Anonymous user