Skip to content

Instantly share code, notes, and snippets.

@jcchurch
Created October 12, 2022 02:38
Show Gist options
  • Save jcchurch/9ff439ec70a119eecbc0ff6c60f53a08 to your computer and use it in GitHub Desktop.
Save jcchurch/9ff439ec70a119eecbc0ff6c60f53a08 to your computer and use it in GitHub Desktop.
My exploration of different die rolling stats for D&D and Risk.
print()
print()
print()
print("D&D")
totals = [0] * 19
for a in range(1, 7):
for b in range(1, 7):
for c in range(1, 7):
for d in range(1, 7):
rolls = [a, b, c, d]
total = sum(rolls) - min(rolls)
totals[total] += 1
def bar_graph(x):
return "#" * (x // 2) + "&" * (x % 2)
for i in range(3, 19):
print(f"{i:5} :: {totals[i]:3} {bar_graph(totals[i])}")
overall_total = 0
for i in range(19):
overall_total += i * totals[i]
print("Overall Average: ", overall_total / (6*6*6*6) )
print()
print()
print()
print("Risk")
def evaluate(attack, defend):
attack.sort()
defend.sort()
i = 1
result = 0
skirmishes = 0
while i <= len(attack) and i <= len(defend):
skirmishes += 1
if defend[-i] >= attack[-i]:
result -= 1
else:
result += 1
i += 1
return (result, skirmishes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment