Created
March 8, 2021 02:41
-
-
Save mw44118/3ca5fceb90c251dcb8c9db91a6b78161 to your computer and use it in GitHub Desktop.
Looks at relative value of rolling with advantage vs 1d20+1, 1d20+3, 1d20+5
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
def _1d20(): | |
return random.choice(range(1, 21)) | |
def roll_with_advantage(): | |
return max([_1d20(), _1d20()]) | |
if __name__ == "__main__": | |
score = collections.defaultdict(int) | |
nat20s = collections.defaultdict(int) | |
for _ in range(1000*1000): | |
a = roll_with_advantage() | |
if a == 20: | |
nat20s["advantage"] += 1 | |
b = _1d20() | |
if b == 20: | |
nat20s["1d20"] += 1 | |
c = _1d20() + 1 | |
if c == 21: | |
nat20s["1d20+1"] += 1 | |
d = _1d20() + 3 | |
if d == 23: | |
nat20s["1d20+3"] += 1 | |
e = _1d20() + 5 | |
if e == 25: | |
nat20s["1d20+5"] += 1 | |
if max([a, b, c, d, e]) == a: | |
score["advantage"] += 1 | |
if max([a, b, c, d, e]) == b: | |
score["1d20"] += 1 | |
if max([a, b, c, d, e]) == c: | |
score["1d20+1"] += 1 | |
if max([a, b, c, d, e]) == d: | |
score["1d20+3"] += 1 | |
if max([a, b, c, d, e]) == e: | |
score["1d20+5"] += 1 | |
pprint.pprint(nat20s) | |
pprint.pprint(score) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment