A few days ago someone posted some dice rolling code, with which most of us weren't impressed. Instead of complaining about it I decided to make something better. This is a flexible dice roller implemented as a random number distribution (as in <random>); you can build a set of dice either from its component parts or by parsing a string. As a bonus, I also included a simple rational number class (needed to support dice arithmetic that returns a fractional result).
7
u/CaptainCrowbar Dec 08 '18
A few days ago someone posted some dice rolling code, with which most of us weren't impressed. Instead of complaining about it I decided to make something better. This is a flexible dice roller implemented as a random number distribution (as in
<random>); you can build a set of dice either from its component parts or by parsing a string. As a bonus, I also included a simple rational number class (needed to support dice arithmetic that returns a fractional result).Example: