Two bullet roulette: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
|||
Line 453: | Line 453: | ||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
{{trans|C}} |
{{trans|C}} |
||
<syntaxhighlight lang="text"> |
<syntaxhighlight lang="text"> |
||
len cyl[] 6 |
|||
func rshift . . |
func rshift . . |
||
h = cyl[ |
h = cyl[6] |
||
for i = |
for i = 6 downto 2 |
||
cyl[i] = cyl[i - 1] |
cyl[i] = cyl[i - 1] |
||
. |
. |
||
cyl[ |
cyl[1] = h |
||
. |
. |
||
func unload . . |
func unload . . |
||
for i |
for i = 1 to 6 |
||
cyl[i] = 0 |
cyl[i] = 0 |
||
. |
. |
||
. |
. |
||
func load . . |
func load . . |
||
while cyl[ |
while cyl[1] = 1 |
||
call rshift |
call rshift |
||
. |
. |
||
cyl[ |
cyl[1] = 1 |
||
call rshift |
call rshift |
||
. |
. |
||
func spin . . |
func spin . . |
||
lim = random 6 |
lim = random 6 |
||
for i = 1 to lim - 1 |
for i = 1 to lim - 1 |
||
call rshift |
call rshift |
||
Line 480: | Line 481: | ||
. |
. |
||
func fire . shot . |
func fire . shot . |
||
shot = cyl[ |
shot = cyl[1] |
||
call rshift |
call rshift |
||
. |
. |
||
Line 487: | Line 488: | ||
shot = 0 |
shot = 0 |
||
for m in m[] |
for m in m[] |
||
if m = |
if m = 1 |
||
call load |
call load |
||
elif m = |
elif m = 2 |
||
call spin |
call spin |
||
elif m = |
elif m = 3 |
||
call fire shot |
call fire shot |
||
if shot = 1 |
if shot = 1 |
||
Line 502: | Line 503: | ||
func test m[] . . |
func test m[] . . |
||
n = 100000 |
n = 100000 |
||
for i |
for i = 1 to n |
||
call method m[] shot |
call method m[] shot |
||
sum += shot |
sum += shot |
||
. |
. |
||
for |
for i = 1 to len m[] |
||
write method$[m] & " " |
write method$[m[i]] & " " |
||
. |
. |
||
print "-> " & 100 * sum / n & "% |
print "-> " & 100 * sum / n & "% death" |
||
. |
. |
||
call test [ |
call test [ 1 2 1 2 3 2 3 ] |
||
call test [ |
call test [ 1 2 1 2 3 3 ] |
||
call test [ |
call test [ 1 1 2 3 2 3 ] |
||
call test [ |
call test [ 1 1 2 3 3 ] |
||
</syntaxhighlight> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |