Dice rolling improvement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dice rolling improvement

Stéphane Rollandin
Hello,

I implemented an improved version of Random>>#roll: (attached)

It has two more operators, > and <, that can be used to discard
respectively a number of lowest or highest throw results. This is used
to skew the random distribution to the left or to the right.

The idea is illustrated here:
https://www.gmdice.com/blogs/dnd/dice-probability-explained


So for example,

        Random roll: '3d6>2'

will roll three d6 and discard two of them, keeping only the best result.

Similarly:

        Random roll: '3d6<1'

rolls three d6 and discards the lowest result.

For consistency, the algorithm takes offsets into account:

        Random roll: '3d6>2+10'

adds 10 to the two best throws, while

        Random roll: '3d6+10>2'

will keep 10 and the best throw among the three d6.


What do you think? Should I submit the code to the inbox?


Stef



Random-roll.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dice rolling improvement

marcel.taeumel
Hi Stef.

+1 :-)

What do you think? Should I submit the code to the inbox?

Sure. Or I can directly merge the changeset you attached. Would you also add tests about that to RandomTest >> #testRoll?

Best,
Marcel

Am 15.04.2020 18:45:02 schrieb Stéphane Rollandin <[hidden email]>:

Hello,

I implemented an improved version of Random>>#roll: (attached)

It has two more operators, > and <, that="" can="" be="" used="" to="" discard="">
respectively a number of lowest or highest throw results. This is used
to skew the random distribution to the left or to the right.

The idea is illustrated here:
https://www.gmdice.com/blogs/dnd/dice-probability-explained


So for example,

Random roll: '3d6>2'

will roll three d6 and discard two of them, keeping only the best result.

Similarly:

Random roll: '3d6<1'>

rolls three d6 and discards the lowest result.

For consistency, the algorithm takes offsets into account:

Random roll: '3d6>2+10'

adds 10 to the two best throws, while

Random roll: '3d6+10>2'

will keep 10 and the best throw among the three d6.


What do you think? Should I submit the code to the inbox?


Stef