Created
August 10, 2021 09:22
-
-
Save sminez/bf60e2ef9baa6f26ab2a05e2a98b65f3 to your computer and use it in GitHub Desktop.
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
''' | |
Checking alternative dice probabilities for Ironsworn | |
''' | |
from collections import defaultdict | |
import json | |
MODIFIERS = [0, 1, 2, 3, 4] | |
STRONG = "strong hit" | |
WEAK = "weak hit" | |
MISS = "miss" | |
def result(action, c1, c2): | |
if action > c1 and action > c2: | |
return STRONG | |
elif action > c1 or action > c2: | |
return WEAK | |
return MISS | |
def counts(action, challenge): | |
res = defaultdict(lambda: { STRONG: 0.0, WEAK: 0.0, MISS: 0.0 }) | |
total = 0 | |
for a in range(1, action+1): | |
for c1 in range(1, challenge+1): | |
for c2 in range(1, challenge+1): | |
for m in MODIFIERS: | |
res[m][result(a+m, c1, c2)] += 1 | |
total += 1 | |
for m in MODIFIERS: | |
for kind in [STRONG, WEAK, MISS]: | |
res[m][kind] = round(res[m][kind] / total * 100, 2) | |
print(f"Outcome probabilities for using d{action} vs 2d{challenge}:") | |
print(json.dumps(dict(res), indent=2)) | |
print() | |
if __name__ == '__main__': | |
counts(6, 6) # Original PbtA | |
counts(6, 10) # Ironsworn | |
# Alternatives | |
counts(8, 10) | |
counts(6, 8) | |
counts(4, 8) | |
counts(8, 12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment