Last active
December 15, 2015 17:59
-
-
Save jsrn/5300045 to your computer and use it in GitHub Desktop.
A random number generator to be used as a substitute for dice in a tabletop RPG. Given properly formatted input, outputs a series of random numbers, e.g. 4d12 rolls four 12-sided dice.
This file contains 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
import random; | |
print "Usage:"; | |
print "[N]d[M]"; | |
print "where N is the number of dice and M is the size of the die."; | |
while 1: | |
try: | |
a = raw_input("Roll: "); | |
inp = a.split('d'); | |
if(a == ""): | |
break; | |
for i in range(int(inp[0])): | |
print random.randint(1,int(inp[1])); | |
except ValueError: | |
print "Example: 2d10"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment