Skip to content

Instantly share code, notes, and snippets.

@PaulReiber
Last active November 18, 2019 22:27
Show Gist options
  • Select an option

  • Save PaulReiber/b9b9f30de8f60ff7931d45ce2e08f0c4 to your computer and use it in GitHub Desktop.

Select an option

Save PaulReiber/b9b9f30de8f60ff7931d45ce2e08f0c4 to your computer and use it in GitHub Desktop.
quick example code - d&d dice roll in python
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