Dicebag is an extension containing probability functions designed specifically for games. Relying on purely math.random() to create probability in games leads to symmetric results that feel bad for humans. Dicebag aims to provide functionality to create probability that feels good for players.
Inspired by this excellent blog post: https://www.redblobgames.com/articles/probability/damage-rolls.html
You can do things like set up good RNG (randomseed), flip a coin, roll dice D&D style, roll dice with advantage/disadvantage, roll custom dice (with varying side weights and values), draw marbles from bags (to create increasing chance of success for rare events, for example) and roll values from a table.
Read more here:
It hasn’t been battle tested in real projects yet, so tread with caution (and make sure to add a specific release to your project rather than the master zip in case there are breaking changes in updates).
I would welcome contributions from anyone that is interested, such as:
- Issues/lack of clarity in documentation;
- Fixes or efficiency improvements in existing functions;
- Addition of new functionality that I may have missed; and
- Anything else you can think of!
Let me know what you think!