Anonymous user
Monty Hall problem: Difference between revisions
→{{header|AutoHotkey}}
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: use fix-size array and atomic increment in .race block) |
|||
Line 224:
=={{header|AutoHotkey}}==
<lang ahk>#
Iterations = 1000
Loop, %Iterations%
Line 244 ⟶ 241:
Incorrect_Stay++
}
Percent_Change :=
MsgBox,, Monty Hall Problem, These are the results:`r`n`r`nWhen I changed my guess, I got %Correct_Change% of %Iterations% (that's %Incorrect_Change% incorrect).
ExitApp
Monty_Hall(Mode) ;Mode is 1 for change, 2 for random, or 3 for stay
{
show := guess = actual ? guess = 3 ? guess - rand : guess = 1 ? guess+rand : guess + 2*rand - 3 : 6 - guess - actual
▲ Random, show, 1, 3
Mode := Mode = 2 ? 2*rand - 1: Mode
Return, Mode = 1 ?
}</lang>
Sample output:
Line 270 ⟶ 262:
These are the results:
When I changed my guess, I got
When I randomly changed my guess, I got 572 of 1000 (that's 428 incorrect). Thats 57% correct.▼
When I
▲When I
</pre>
|