Dicebag - probability for games

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! :game_die:

18 Likes

I really like this. It’s a fun idea and frequently relevant.

2 Likes

Thank you! I’ve wanted to give back somehow for a long time, but couldn’t think of something that was a) within my capacity, and b) something that’s actually useful. Here we are!

1 Like

Loving this, thanks @Alex_8BitSkull!

1 Like

Ooh, very nice… I love this idea @Alex_8BitSkull, thank you! :slight_smile:

1 Like