MemeLabs / modbot

https://chat.strims.gg/
3 stars 6 forks source link

da dice roll #57

Closed mafaraxas closed 1 year ago

mafaraxas commented 1 year ago

https://github.com/MemeLabs/modbot/blob/e8162898beb7dece65bc325a250f22adf3da7eb0/commands.go#L565C17-L565C17

The formula (in a nutshell)

int63n( int(sides-1) * count ) + count

isn't quite accurate to independent dice rolls. With count>1, all possible numbers are equally likely. Two six-sided dice (for example) have 7 being the most likely sum, and 2 or 12 least likely. So, it requires "count" number of calls to this rng; roughly,

s = 0; for i=1 to count inclusive, s = s + int63n( int(sides) ) + 1 end for return s

Probably means there should be an upper limit to number of dice to roll at once.

(note - also don't need sides-1, since int63n doesn't include the final value in the argument; int63n(2) gives 0 or 1 for example. (I'm only getting the number 1 when rolling a 2-sided dice.)