Skip to content

Instantly share code, notes, and snippets.

@cozos
Created September 3, 2018 07:11
Show Gist options
  • Save cozos/cff1ff5c30e4e2e17c7b7db6cee1ab29 to your computer and use it in GitHub Desktop.
Save cozos/cff1ff5c30e4e2e17c7b7db6cee1ab29 to your computer and use it in GitHub Desktop.
import math
import random
rolls = [[random.randint(1,6) for i in xrange(4)] for j in xrange(6)]
# remove lowest roll
for roll in rolls:
roll.remove(min(roll))
stats = [sum(roll) for roll in rolls]
random.shuffle(stats)
ATTRIBUTES = ["STR", "DEX", "CON", "INT", "WIS", "CHA"]
print [
"{}: {} ({:+})".format(ATTRIBUTES[i], stats[i], int(math.floor((stats[i]-10)/2)))
for i in xrange(len(ATTRIBUTES))
]
print "Average: {}".format(sum(stats) / len(stats))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment