Anonymous user
Two bullet roulette: Difference between revisions
m
→{{header|REXX}}: optimized execution which yields around 30% speed improvement.
m (→{{header|REXX}}: optimized execution which yields around 30% speed improvement.) |
|||
Line 1,003:
if tests=='' | tests=="," then tests= 100000 /* " " " " " " */
if datatype(seed, 'W') then call random ,,seed /* " " " " " " */
cyls_ = cyls - 1; @0= copies(0,
@abc= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
scenarios= '
#= words(scenarios) /*the number of actions in a scenario. */
/*The scenarios are case insensitive. */
do m=1 for #; q= word(scenarios, m)
do tests;
end /*tests*/
pc= left( (sum * 100 / tests)"%", 7)
say act()
end /*m*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
fire: != left(@, 1); @=
load: if left(@, 1) then @=
spin: ?= random(1, cyls); if ?\==cyls then @= substr(@ || @, ? + 1, cyls); return
/*──────────────────────────────────────────────────────────────────────────────────────*/
method: @=
else if y=='F' then if fire() then return 1
end /*a*/;
/*──────────────────────────────────────────────────────────────────────────────────────*/
act: $=;
end /*a*/;
{{out|output|text= when using the default inputs, showing that 2<sup>nd</sup> option '''B''' has the highest probability for a suicide:}}
<pre>
|