19 lines
477 B
Text
19 lines
477 B
Text
procedure main(arglist)
|
|
|
|
rounds := integer(arglist[1]) | 10000
|
|
doors := '123'
|
|
strategy1 := strategy2 := 0
|
|
|
|
every 1 to rounds do {
|
|
goats := doors -- ( car := ?doors )
|
|
guess1 := ?doors
|
|
show := goats -- guess1
|
|
if guess1 == car then strategy1 +:= 1
|
|
else strategy2 +:= 1
|
|
}
|
|
|
|
write("Monty Hall simulation for ", rounds, " rounds.")
|
|
write("Strategy 1 'Staying' won ", real(strategy1) / rounds )
|
|
write("Strategy 2 'Switching' won ", real(strategy2) / rounds )
|
|
|
|
end
|