Jump to content

Dice game probabilities: Difference between revisions

m
REXX is to be reviewed
m (→‎optimized: changed a comment, moved a statement.)
m (REXX is to be reviewed)
Line 1,187:
=={{header|REXX}}==
===Algorithm===
 
{{Needs-review|REXX| <br> There may have been some cut-and-paste errors (with HTML tags) introduced while creating this entry. <br><br>}}
 
{{trans|ooRexx}}
(adapted for Classic Rexx)
Line 1,254 ⟶ 1,251:
res=res p.x
End
Return res</lang>
{{out}}
<br>Result from 100.000 tries.
<pre>
<br>Result from 100.000 tries.
tbd</pre>
===tbd===
<lang rexx>oid='diet.xxx'; Call sysFileDelete oid
Call test '9 4 6 6'
Line 1,316 ⟶ 1,317:
numeric digits 100 /*increase│decrease for heart's desire.*/
call game 9 4, 6 6 /*1st player: 9 dice, 4 sides; 2nd player: 6 dice, 6 sides*/
say
call game 5 10, 6 7 /* " " 5 " 10 " " " 6 " 7 " */
exit /*stick a fork in it, we're all done. */
Line 1,334 ⟶ 1,336:
end /*j*/
say 'The % probability for first player to win is ' format(winP*100, , 30) "%."
say /* ↑ */
return /*display 30 decimal digits────┘ */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 1,344 ⟶ 1,345:
do k=n to ns; $=$ p.k; end /*k*/
return $ /* ◄──────────────── probability of 1st player to win, S─sided, N dice.*/</lang>
{{out}}
'''output'''
<pre>
Player 1 has 9 dice with 4 sides each.
2,300

edits

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