Jump to content

Two bullet roulette: Difference between revisions

m (Added language identifier.)
Line 455:
<syntaxhighlight lang="text">
len cyl[] 6
funcproc rshift . .
h = cyl[6]
for i = 6 downto 2
cyl[i] = cyl[i - 1]
.
cyl[1] = h
.
funcproc unload . .
for i = 1 to 6
cyl[i] = 0
.
.
funcproc load . .
while cyl[1] = 1
call rshift
.
cyl[1] = 1
call rshift
.
funcproc spin . .
lim = random 6
for i = 1 to lim - 1
call rshift
.
.
funcproc fire . shot .
shot = cyl[1]
call rshift
.
funcproc method m[] . shot .
call unload
shot = 0
for m in m[]
if m = 1
call load
elif m = 2
call spin
elif m = 3
call fire shot
if shot = 1
break 1
.
.
.
.
.
method$[] = [ "load" "spin" "fire" ]
funcproc test m[] . .
n = 100000
for i = 1 to n
call method m[] shot
sum += shot
.
for i = 1 to len m[]
write method$[m[i]] & " "
.
print "-> " & 100 * sum / n & "% death"
.
call test [ 1 2 1 2 3 2 3 ]
1,969

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.