[squeak-dev] Dice rolling improvement

Marcel Taeumel marcel.taeumel at hpi.de
Fri Apr 17 09:17:26 UTC 2020


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 <lecteur at zogotounga.net>:
Hello,

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

It has two more operators, > and
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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200417/cc771164/attachment.html>


More information about the Squeak-dev mailing list