34 lines
1 KiB
Text
34 lines
1 KiB
Text
#90 = Time_Tick // seed for random number generator
|
|
#91 = 3 // random numbers in range 0 to 2
|
|
#1 = 0 // wins for "always stay" strategy
|
|
#2 = 0 // wins for "always switch" strategy
|
|
for (#10 = 0; #10 < 10000; #10++) { // 10,000 iterations
|
|
Call("RANDOM")
|
|
#3 = Return_Value // #3 = winning door
|
|
Call("RANDOM")
|
|
#4 = Return_Value // #4 = players choice
|
|
do {
|
|
Call("RANDOM")
|
|
#5 = Return_Value // #5 = door to open
|
|
} while (#5 == #3 || #5 == #4)
|
|
if (#3 == #4) { // original choice was correct
|
|
#1++
|
|
}
|
|
if (#3 == 3 - #4 - #5) { // switched choice was correct
|
|
#2++
|
|
}
|
|
}
|
|
Ins_Text("Staying wins: ") Num_Ins(#1)
|
|
Ins_Text("Switching wins: ") Num_Ins(#2)
|
|
return
|
|
|
|
//--------------------------------------------------------------
|
|
// Generate random numbers in range 0 <= Return_Value < #91
|
|
// #90 = Seed (0 to 0x7fffffff)
|
|
// #91 = Scaling (0 to 0xffff)
|
|
|
|
:RANDOM:
|
|
#92 = 0x7fffffff / 48271
|
|
#93 = 0x7fffffff % 48271
|
|
#90 = (48271 * (#90 % #92) - #93 * (#90 / #92)) & 0x7fffffff
|
|
return ((#90 & 0xffff) * #91 / 0x10000)
|