Dice notation tools
This notation is widely used on tabletop games, such as wargames or RPGs, and was created on the late 70s for Dungeons & Dragons, as a way to allow generating random values in specific distributions.
With the pass of years it has evolved, and while it never underwent a formal standarization process a core set of rules is kept among all the variations, mostly representing dice in a format such as ‘1d6’, and the use of algebra operations like addition and subtraction.
This project aims to give support to the dice notation, allowing parsing and operating with it on any Python application.
- Ply-based parser to generate objects for dice notation
- Easy-to-use objects to handle the notation, just call the ‘roll’ method
- Classes to support plain dice
Documentation sources are included with the project, and used to generate the documentation sites:
- The latest docs are always generated for the latest release, kept in the ‘master’ branch
- The development docs are generated from the latest code in the ‘develop’ branch
You can also create the documentation from the source files, kept in the ‘docs’ folder, with the help of Sphinx. For this use the makefile, or the make.bat file, contained on that folder.
The project has been tested in the following versions of the interpreter:
- Python 3.4
- Python 3.5
- Python 3.6
All other dependencies are indicated on the requirements.txt file.
These can be installed with:
$ pip install --upgrade -r requirements.txt
The project is offered as a Pypi package, and using pip is the preferred way to install it. For this use the following command;
$ pip install dice-notation
If needed, manual installation is possible:
$ python setup.py install
The application has been coded in Python, and does not require any particular framework.
To use it just import the parser:
from dice_notation.parser import DiceParser
And then use it to parse a dice notation expression:
parser = DiceParser() dice = parser.parse('1d6+2')
The result can be accessed just by calling the ‘roll’ method as many times as needed, which will generate a new random value each time it is called:
The tests included with the project can be run with:
$ python setup.py test
This will delegate the execution to tox.
It is possible to run just one of the test profiles, in this case the py36 profile:
$ python setup.py test -p "py36"
Any kind of help with the project will be well received, and there are two main ways to give such help:
- Reporting errors and asking for extensions through the issues management
- or forking the repository and extending the project
Issues are managed at the GitHub project issues tracker, where any Github user may report bugs or ask for new features.
Getting the code
If you wish to fork or modify the code, visit the GitHub project page, where the latest versions are always kept. Check the ‘master’ branch for the latest release, and the ‘develop’ for the current, and stable, development version.
The project has been released under the MIT License.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size dice_notation-1.0.6-py3.6.egg (43.9 kB)||File type Egg||Python version 3.6||Upload date||Hashes View hashes|
|Filename, size dice_notation-1.0.6-py3-none-any.whl (22.0 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size dice-notation-1.0.6.tar.gz (45.7 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for dice_notation-1.0.6-py3-none-any.whl