Created
July 20, 2021 20:21
-
-
Save eloj/9b8145ad05b5441301b9daa6be7f4f76 to your computer and use it in GitHub Desktop.
Roll for D20/D&D 5ed ability scores (python)
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
#!/usr/bin/env python3 | |
# | |
# Roll for D20/D&D 5ed ability scores. | |
# Using procedure in Player's Handbook for D&D 5ed, p13. | |
# "Roll four 6-sided dice and record the total of the highest three" | |
# | |
import random | |
total = 0 | |
for i in range(6): | |
rolls = [random.randint(1,6) for _ in range(4)] | |
score = sum(sorted(rolls)[1:]) | |
total += score | |
print(f"{i+1}: Rolled {rolls}, ability score is {score}") | |
print(f"total {total}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment