{"id":21434059,"url":"https://github.com/bernardo-mg/dice-notation-python","last_synced_at":"2026-03-10T06:33:16.468Z","repository":{"id":10971694,"uuid":"67716224","full_name":"Bernardo-MG/dice-notation-python","owner":"Bernardo-MG","description":"Tools and parsers for handling Dice/RPG notation using Python","archived":false,"fork":false,"pushed_at":"2022-12-27T16:20:06.000Z","size":194,"stargazers_count":4,"open_issues_count":8,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-14T08:50:15.403Z","etag":null,"topics":["dice-notation","parser"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bernardo-MG.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-08T15:34:48.000Z","updated_at":"2022-02-28T21:03:07.000Z","dependencies_parsed_at":"2023-01-13T16:15:55.433Z","dependency_job_id":null,"html_url":"https://github.com/Bernardo-MG/dice-notation-python","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernardo-MG%2Fdice-notation-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernardo-MG%2Fdice-notation-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernardo-MG%2Fdice-notation-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernardo-MG%2Fdice-notation-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bernardo-MG","download_url":"https://codeload.github.com/Bernardo-MG/dice-notation-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225980898,"owners_count":17554919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dice-notation","parser"],"created_at":"2024-11-22T23:32:54.961Z","updated_at":"2026-03-10T06:33:16.421Z","avatar_url":"https://github.com/Bernardo-MG.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==============================\nDice Notation Tools for Python\n==============================\n\nThis notation is widely used on tabletop games, such as wargames or RPGs, and\nwas created on the late 70s for Dungeons \u0026 Dragons, as a way to allow generating\nrandom values in specific distributions.\n\nWith the pass of years it has evolved, and while it never underwent a formal\nstandarization process a core set of rules is kept among all the variations,\nmostly representing dice in a format such as '1d6', and the use of algebra\noperations like addition and subtraction.\n\nThis project aims to give support to the dice notation, allowing parsing and\noperating with it on any Python application.\n\n.. image:: https://badge.fury.io/py/dice-notation.svg\n    :target: https://pypi.python.org/pypi/dice-notation\n    :alt: Dice Notation Tools for Python Pypi package page\n\n.. image:: https://img.shields.io/badge/docs-release-blue.svg\n    :target: https://docs.bernardomg.com/dice-notation-python\n    :alt: Dice Notation Tools for Python latest documentation\n.. image:: https://img.shields.io/badge/docs-develop-blue.svg\n    :target: https://docs.bernardomg.com/development/dice-notation-python\n    :alt: Dice Notation Tools for Python development documentation\n\nFeatures\n--------\n\n- ANTLR-based parser generates objects from dice notation (BNF grammar included)\n- Easy-to-use model, just call the 'roll' method\n- Classes to support plain dice\n\nDocumentation\n-------------\n\nDocumentation sources are included with the project, and used to generate the\ndocumentation sites:\n\n- The `latest docs`_ are always generated for the latest release, kept in the 'master' branch\n- The `development docs`_ are generated from the latest code in the 'develop' branch\n\nThe source files for the docs, a small `Sphinx`_ project, are kept in the 'docs folder.\n\nThese can be built if needed:\n\n``python setup.py build_docs``\n\nPrerequisites\n~~~~~~~~~~~~~\n\nThe project has been tested in the following versions of the interpreter:\n\n- Python 3.6\n- Python 3.7\n- Python 3.8\n\nAll other dependencies are indicated on the requirements.txt file.\n\nThese can be installed with:\n\n``pip install --upgrade -r requirements.txt``\n\nBuilding the grammar\n~~~~~~~~~~~~~~~~~~~~\n\nFirst of all install ANTLR `as told here \u003chttps://github.com/antlr/antlr4/blob/master/doc/getting-started.md/\u003e`_.\n\nAfterwards, follow `these indications \u003chttps://github.com/antlr/antlr4/blob/master/doc/python-target.md/\u003e`_.\n\nThe command to generate the parser will be:\n\n``antlr4 -Dlanguage=Python2 DiceNotation.g4 DiceNotationLexer.g4``\n\nInstalling\n~~~~~~~~~~\n\nThe project is offered as a `Pypi package`_, and using pip is the preferred way\nto install it. For this use the following command;\n\n``pip install dice-notation``\n\nIf needed, manual installation is possible:\n\n``python setup.py install``\n\nUsage\n-----\n\nThe application has been coded in Python, and does not require any particular\nframework.\n\nTo use it just import the parser::\n\n    from dice_notation.parser import DiceParser\n\nAnd then use it to parse a dice notation expression::\n\n    parser = DiceParser()\n    dice = parser.parse('1d6+2')\n\nThe result can be accessed just by calling the 'value' method as many times as\nneeded, which will generate a new random value each time it is called::\n\n    print(dice.roll())\n    print(dice.roll())\n\nTesting\n-------\n\nThe tests included with the project can be run with:\n\n``python setup.py test``\n\nThis will delegate the execution to tox.\n\nIt is possible to run just one of the test profiles, in this case the py36 profile:\n\n``python setup.py test -p \"py38\"``\n\nCollaborate\n-----------\n\nAny kind of help with the project will be well received, and there are two main ways to give such help:\n\n- Reporting errors and asking for extensions through the issues management\n- or forking the repository and extending the project\n\nIssues management\n~~~~~~~~~~~~~~~~~\n\nIssues are managed at the GitHub `project issues tracker`_, where any Github\nuser may report bugs or ask for new features.\n\nGetting the code\n~~~~~~~~~~~~~~~~\n\nIf you wish to fork or modify the code, visit the `GitHub project page`_, where\nthe latest versions are always kept. Check the 'master' branch for the latest\nrelease, and the 'develop' for the current, and stable, development version.\n\nLicense\n-------\n\nThe project has been released under the `MIT License`_.\n\n.. _GitHub project page: https://github.com/Bernardo-MG/dice-notation-python\n.. _latest docs: https://docs.bernardomg.com/dice-notation-python\n.. _development docs: https://docs.bernardomg.com/development/dice-notation-python\n.. _Pypi package: https://pypi.python.org/pypi/dice-notation\n.. _MIT License: https://opensource.org/licenses/mit-license.php\n.. _project issues tracker: https://github.com/Bernardo-MG/dice-notation-python/issues\n.. _Sphinx: https://www.sphinx-doc.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernardo-mg%2Fdice-notation-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbernardo-mg%2Fdice-notation-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernardo-mg%2Fdice-notation-python/lists"}