{ "info": { "author": "Mark Brockett Robson", "author_email": "mark.brockett.robson@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Python dice ![logo](https://raw.githubusercontent.com/markbrockettrobson/python_dice/master/images/pythondice_logo_128x128.png)\r\n\r\n\r\n[![codecov](https://codecov.io/gh/markbrockettrobson/python_dice/branch/master/graph/badge.svg)](https://codecov.io/gh/markbrockettrobson/python_dice)\r\n[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\r\n![license](https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png)\r\n\r\na statistical dice engine for python\r\n\r\n### License \r\n\r\nThis work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License\r\nhttp://creativecommons.org/licenses/by-nc-sa/4.0/\r\n\r\n### To install\r\n~~~\r\npython -m pip install python_dice\r\n~~~\r\n\r\n### Source at \r\nhttps://github.com/markbrockettrobson/python_dice\r\n\r\n### Usage\r\n\r\n~~~\r\nfrom python_dice import PythonDiceInterpreter\r\n\r\ninterpreter = PythonDiceInterpreter()\r\nprogram = [\"1d6\"]\r\nroll = interpreter.roll(program)[\"stdout\"]\r\nprint(roll)\r\n\r\n> 3\r\n~~~\r\n\r\n~~~\r\nfrom python_dice import PythonDiceInterpreter\r\n\r\ninterpreter = PythonDiceInterpreter()\r\nprogram = [\r\n \"VAR a_name = d6 + 10\",\r\n \"VAR b_name = d6 - 10\"\r\n]\r\na_name = interpreter.max(program)[\"a_name\"]\r\nb_name = interpreter.min(program)[\"b_name\"]\r\nprint(a_name, b_name)\r\n\r\n> 16 -9\r\n~~~\r\n\r\n~~~\r\ninterpreter = python_dice_interpreter.PythonDiceInterpreter()\r\nprogram = [\r\n \"VAR save_roll = d20\",\r\n \"VAR burning_arch_damage = 10d6 + 10\",\r\n \"VAR pass_save = ( save_roll >= 10 ) \",\r\n \"VAR damage_half_on_save = burning_arch_damage // (pass_save + 1)\",\r\n \"damage_half_on_save\"\r\n]\r\nim = interpreter.get_histogram(program)\r\nim.show()\r\n~~~\r\n![image of 10d6 add 10 half round up if 1d20 greater than 10](https://raw.githubusercontent.com/markbrockettrobson/python_dice/master/images/histogram.png)\r\n\r\n### Syntax\r\n#### Dice\r\n~~~\r\nd\r\n4d10\r\nd6\r\n1d%\r\n30dF\r\n2d[1,1,2,3,5,8]\r\n~~~\r\n\r\nnumber of dice is missing will be treated as one.
\r\nnumber of sides can also be:
\r\n+ % for 100.\r\n+ F for fate dice [-1,0,1].\r\n+ custom dice with a comma separated list of side values in [ ] square brackets (trailing comma allowed).\r\n+ range of values d[1,2,3,4,5] == d[1-5] ==d5\r\n + d[-5,-4,-3,-2] == d[-5--2] == d[-2--5]\r\n+ multiplier for many equal sides d[1,1,1,1,1,1,1,8] == d[1*7, 8]\r\n + d[1,1,1,2,2,3,3,4] == d[1-3*2,1,4] \r\n\r\n\r\n#### Keep Drop\r\n~~~\r\nd[k for keep d for drop]\r\n2d20k1 roll 2 d20's take the highest 1\r\n16d%k10 roll 16 d% keep the hightest 10\r\n10d[-1,1]d5 roll 10 d[-1,1]'s drop the highest 5\r\n2dFd1 roll 2 dF's drop the highest 1\r\n~~~\r\n\r\nIf the number of dice to keep is set above the number of dice to roll it will keep all dice.
\r\nIf the number to drop is equal or greater then the number of dice to roll it will always roll 0.
\r\nIf the number of dice to keep is set to zero then it will always roll 0.
\r\nIf the number of dice to drop is set to zero then it will be ignored.
\r\n\r\n#### Set a var\r\n~~~\r\nVAR lower_case_name = 1\r\nVAR name = 4d20\r\n~~~\r\n#### Add, subtract, multiply, integer division\r\n~~~\r\nVAR name = 1 + 2d3 - 3 * 4d2 // 5\r\n~~~\r\n#### Parenthesis\r\n~~~\r\nVAR out = 3 * ( 1 + 1d4 )\r\n~~~\r\n#### Binary operator\r\n~~~\r\nVAR a = 1d4 == 1\r\nVAR b = 1d4 != 1\r\nVAR c = 1d4 <= 2\r\nVAR d = 1d4 < 3\r\nVAR e = 1d4 >= 2\r\nVAR f = 1d4 > 2\r\nVAR g = (1d4 >= 2) AND !(1d20 == 2)\r\nVAR h = (1d4 >= 2) OR !(1d20 == 2)\r\n~~~\r\nfor non binary values, values above 0 are considered true.\r\n\r\n#### Abs\r\n~~~\r\nVAR abs = ABS( 1d6 - 1d6 )\r\n~~~\r\n#### Min and Max\r\n~~~\r\nMAX(4d7, 2d10)\r\nMIN(50, d%)\r\n~~~\r\n\r\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/markbrockettrobson/python_dice", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "python-dice", "package_url": "https://pypi.org/project/python-dice/", "platform": "", "project_url": "https://pypi.org/project/python-dice/", "project_urls": { "Homepage": "https://github.com/markbrockettrobson/python_dice" }, "release_url": "https://pypi.org/project/python-dice/2.0.2/", "requires_dist": null, "requires_python": ">=3.6", "summary": "a statistical dice library for python", "version": "2.0.2", "yanked": false, "yanked_reason": null }, "last_serial": 12213073, "releases": { "1.4.3": [ { "comment_text": "", "digests": { "md5": "30955a1e955564002e2ecbbe026733c3", "sha256": "2a2c412955f13a03dfc23391334bf6191a3c9c3dba0e55703fd0b70563a6b764" }, "downloads": -1, "filename": "python_dice-1.4.3.tar.gz", "has_sig": false, "md5_digest": "30955a1e955564002e2ecbbe026733c3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 17747, "upload_time": "2020-10-04T08:30:56", "upload_time_iso_8601": "2020-10-04T08:30:56.937008Z", "url": "https://files.pythonhosted.org/packages/c0/5f/58be1c194b203d310ec77228c09d2d3355a449fe5e68135f8a30d07792fe/python_dice-1.4.3.tar.gz", "yanked": false, "yanked_reason": null } ], "1.4.4": [ { "comment_text": "", "digests": { "md5": "cf1d112051b18768164af95c4a3a3049", "sha256": "932aeb946754754e5ac738e6e5bcd763160c1e484a9a12b9f4af1b24ac640caf" }, "downloads": -1, "filename": "python_dice-1.4.4.tar.gz", "has_sig": false, "md5_digest": "cf1d112051b18768164af95c4a3a3049", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 17930, "upload_time": "2020-10-08T11:59:18", "upload_time_iso_8601": "2020-10-08T11:59:18.722782Z", "url": "https://files.pythonhosted.org/packages/20/87/bc04d8c97e3968e81e84d4cd1024dff2ea793e4ef76b792dbf10776baa6c/python_dice-1.4.4.tar.gz", "yanked": false, "yanked_reason": null } ], "1.4.5": [ { "comment_text": "", "digests": { "md5": "ed3e0986ea6de8563d80c49e277d638d", "sha256": "6b9bc1159a5c4e755f1992fb4ff634f877f9ee1986b117be839cdfae976f6af7" }, "downloads": -1, "filename": "python_dice-1.4.5.tar.gz", "has_sig": false, "md5_digest": "ed3e0986ea6de8563d80c49e277d638d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 17944, "upload_time": "2021-04-02T08:55:30", "upload_time_iso_8601": "2021-04-02T08:55:30.322902Z", "url": "https://files.pythonhosted.org/packages/4d/b6/df304ecd016d05b0149c9a7bf29f600b91d54139e903acc2e7e216683cf2/python_dice-1.4.5.tar.gz", "yanked": false, "yanked_reason": null } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "ee044675cf8577c28eb575e42f7e0159", "sha256": "5ad6452ca35c77e4156f18be87cfbecd2347bb36d0797b279e71ec93ef22090b" }, "downloads": -1, "filename": "python_dice-2.0.0.tar.gz", "has_sig": false, "md5_digest": "ee044675cf8577c28eb575e42f7e0159", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 25027, "upload_time": "2021-05-02T09:06:17", "upload_time_iso_8601": "2021-05-02T09:06:17.055055Z", "url": "https://files.pythonhosted.org/packages/f3/2f/3f68276d684aa09bc8d97e27b15fb6ec228341308b1b822bf5d3f348292d/python_dice-2.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "d70a8464294bda7d2c2c6089096850ae", "sha256": "10cdf2d037021f7313be944f8a89ca8ddd97683c2a367296b157b0a66e5629c8" }, "downloads": -1, "filename": "python_dice-2.0.1.tar.gz", "has_sig": false, "md5_digest": "d70a8464294bda7d2c2c6089096850ae", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 25364, "upload_time": "2021-05-02T12:36:47", "upload_time_iso_8601": "2021-05-02T12:36:47.008647Z", "url": "https://files.pythonhosted.org/packages/13/93/623053dcf82841a2146a5a5d2adfb65a3c386a0c469c535b3904c0a563c2/python_dice-2.0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "ded4e8792ef4212694cf6dda9e8defd3", "sha256": "a15385ac23ee853288a361430a168ed41f06a045b22c6d96c5161b05b7b456f3" }, "downloads": -1, "filename": "python_dice-2.0.2.tar.gz", "has_sig": false, "md5_digest": "ded4e8792ef4212694cf6dda9e8defd3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 593520, "upload_time": "2021-12-05T08:12:37", "upload_time_iso_8601": "2021-12-05T08:12:37.856046Z", "url": "https://files.pythonhosted.org/packages/a1/69/50efe5d24aa52e6c360d882e82b67047a503a92b0073fbaa15982a87021b/python_dice-2.0.2.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ded4e8792ef4212694cf6dda9e8defd3", "sha256": "a15385ac23ee853288a361430a168ed41f06a045b22c6d96c5161b05b7b456f3" }, "downloads": -1, "filename": "python_dice-2.0.2.tar.gz", "has_sig": false, "md5_digest": "ded4e8792ef4212694cf6dda9e8defd3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 593520, "upload_time": "2021-12-05T08:12:37", "upload_time_iso_8601": "2021-12-05T08:12:37.856046Z", "url": "https://files.pythonhosted.org/packages/a1/69/50efe5d24aa52e6c360d882e82b67047a503a92b0073fbaa15982a87021b/python_dice-2.0.2.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }