Skip to main content

An efficient dice notation parser with extended notation

Project description

GNOLL

Test: Functionality Test: Language Bindings Test: OS Support

CodeFactor Codacy Badge

status TTRPG compatibility rate GitHub license GitHub last commit Donate

An easy to integrate dice notation library for multiple programming languages. Use for instant support of common syntax and a library that can scale with your demands, rather than a sticky taped monstrousity of regular expressions and tears.

Here's an example of how you might use GNOLL:

**Grindon The Brave**: I want to steal from the goblin sitting at the bar.
**Dungeon Master**: Okay, give me a stealth check!
**Grindon The Brave**: Okay, that's a <1d20+5>
[GNOLL]: 21
**Dungeon Master**: Hurrah! You successfully pickpocket the goblin! However, all he had in there were some crummy dice...

You can follow Grindon's full adventure through the world of dice notation in our Documentation.

Many of our notation design decisions are explained in the documentation and compared to other dice notation parsers.

Current Status

🧑‍💻 Language Support

GNOLL was written to be the definitive solution to dice notation. The core has been written in C, but fear not! You can use GNOLL in many other programming languages too.

C C++ C# Go Haskell Java JavaScript Julia Perl PHP Python R Ruby

Primarily tested on Linux (Ubuntu), but functional in various forms on Windows (10, WSL) and Mac.

🎲 Dice Notation

  • XdY notation
  • Arithmetic
  • Fate Dice
  • Miscellaneous Symbolic Dice
  • Shorthands & Macros
  • Alternate Syntax
  • Explosions
  • Drop/Keep
  • Rerolling
  • Filtering
  • Functions

There's so many different things, we'd bore you to list them all here. For the specific details of supported notation, check out our documentation.

Getting Started

Usage from a package manager

Python

pip3 install GNOLL

Then, in your code:

from gnoll import roll
roll("1d20")
>> (0, [[12]], None)
# (return code, final result, dice breakdown (if enabled))

🛠️ Installing From Source

Basic Requirements

sudo apt-get install bison flex make python3-pip -y
pip install -r reqs/requirements.txt
make all

To verify your setup, try our tests:

make test

Or, just try some commands yourself!

$ ./build/dice 1d20
20

If you would like to run the 'dice' command from anywhere, use make install to add the executable to your path.

(Note that not all commands may not be able to be used this way as some symbols are reserved for use by different terminal interfaces (e.g. bash uses ! and #))

For languages other than Python/C/C++ call the corresponding make target after the commands above.

🐛 Issues / Bugs / FAQs / Feature Requests

If you encounter any issues or have any ideas, please file them in our Issue Tracker.

✋ Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

🔢 Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

🤹 Authors / Contributers / Attributions

See also the list of contributors who participated in this project.

📃 License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE.md file for details.

Individual licensing arrangements can be made if this is an issue for your project - Contact Me at LinkedIn to discuss.

👏 Acknowledgments

🏗️ Built With

  • Flex & Bison - Grammar Lexing & Parsing
  • uthash - C hashtable lib
  • PCG - Random Number Generation
  • Arc4Random - Random Number Generation (Cryptographically secure)
  • Love! 💖

💰 Donate

Keep this project alive

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

gnoll-4.5.3-cp310-cp310-manylinux1_x86_64.whl (331.7 kB view details)

Uploaded CPython 3.10

File details

Details for the file gnoll-4.5.3-cp310-cp310-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gnoll-4.5.3-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c1eb2ab779fe132aee5b67da1b50a267d5789df71b713c43d045edd4176bdb18
MD5 3a39fab88485a3adeae9a6a1bc6fe0ec
BLAKE2b-256 6426acf7d958cd4701b6e9be023493a6ab7bff2efb9ef8c9b120d915e1b30efb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page