Last active
November 18, 2019 22:27
-
-
Save PaulReiber/b9b9f30de8f60ff7931d45ce2e08f0c4 to your computer and use it in GitHub Desktop.
quick example code - d&d dice roll in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import randint as rand | |
| def roll(**dice): | |
| ret=0 | |
| for key in dice: | |
| val = rand(1, dice[key]) | |
| print("%s: %s" % (key, val)) | |
| ret += val | |
| return(ret) | |
| """ 3d8+5 """ | |
| print(roll(d1=8, d2=8, d3=8) + 5) | |
| print() | |
| """percentile is much simpler | |
| than 1d10x10 + 1d10""" | |
| print(roll(percentage=100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment