Two bullet roulette: Difference between revisions

m
Line 469:
proc load . .
while cyl[1] = 1
call rshift
.
cyl[1] = 1
call rshift
.
proc spin . .
lim = random 6
for i = 1 to lim - 1
call rshift
.
.
procfunc fire . shot .
shot = cyl[1]
call rshift
sum +=return shot
.
procfunc method m[] . shot .
call unload
shot = 0
for m in m[]
if m = 1
call load
elif m = 2
call spin
elif m = 3
callif fire shot= 1
if shot = return 1
break 1
.
.
.
shot =return 0
.
method$[] = [ "load" "spin" "fire" ]
Line 504:
n = 100000
for i = 1 to n
callsum += method m[] shot
sum += shot
.
for i = 1 to len m[]
Line 512 ⟶ 511:
print "-> " & 100 * sum / n & "% death"
.
call test [ 1 2 1 2 3 2 3 ]
call test [ 1 2 1 2 3 3 ]
call test [ 1 1 2 3 2 3 ]
call test [ 1 1 2 3 3 ]
</syntaxhighlight>
 
1,983

edits