Last active
May 16, 2022 08:38
-
-
Save Francesco149/937d2db4c5cff87721b1510350aa3e14 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 python | |
from itertools import product | |
from functools import reduce | |
from operator import mul | |
BOSS = "boss" | |
IED = "ied" | |
ATT = "att" | |
ANY = "any" | |
STAT = "stat" | |
ALLSTAT = "allstat" | |
P = True | |
N = False | |
prime_chance_red = [1, 0.1, 0.01] | |
prime_chance_black = [1, 0.2, 0.05] | |
prime_chance_violet = [1, 0.1, 0.01, 0.01, 0.1, 0.01] | |
prime_chance_equality = [1, 1, 1] | |
prime_chance_bonus = [1, 0.004975, 0.004975] | |
prime_chance_occult = [1] + [1.0/101]*2 | |
prime_lines_weapon = [ | |
(P, BOSS, 40, 20.5), | |
(P, BOSS, 35, 20.5), | |
(P, BOSS, 30, 20.5), | |
(P, IED, 40, 20.5), | |
(P, IED, 35, 20.5), | |
(P, ATT, 12, 20.5), | |
] | |
lines_weapon = [ | |
(N, BOSS, 30, 14.3333), | |
(N, IED, 30, 14.3333), | |
(N, ATT, 9, 14.3333), | |
] | |
prime_lines_secondary = [ | |
(P, BOSS, 40, 23.5), | |
(P, BOSS, 35, 23.5), | |
(P, BOSS, 30, 23.5), | |
(P, IED, 40, 23.5), | |
(P, IED, 35, 23.5), | |
(P, ATT, 12, 23.5), | |
] | |
lines_secondary = [ | |
(N, BOSS, 30, 17.0), | |
(N, IED, 30, 17.0), | |
(N, ATT, 9, 17.0), | |
] | |
prime_lines_emblem = [ | |
(P, IED, 40, 17.5), | |
(P, IED, 35, 17.5), | |
(P, ATT, 12, 17.5), | |
] | |
lines_emblem = [ | |
(N, IED, 30, 13.3333), | |
(N, ATT, 9, 13.3333), | |
] | |
prime_lines_weapon_b = [ | |
(P, ATT, 12, 19.5), | |
] | |
lines_weapon_b = [ | |
(N, ATT, 9, 21.5), | |
] | |
prime_lines_secondary_b = [ | |
(P, ATT, 12, 20.5), | |
] | |
lines_secondary_b = [ | |
(N, ATT, 9, 21.5), | |
] | |
prime_lines_emblem_b = [ | |
(P, ATT, 12, 19), | |
] | |
lines_emblem_b = [ | |
(N, ATT, 9, 21), | |
] | |
prime_lines_top = [ | |
(P, STAT, 12, 17), | |
(P, ALLSTAT, 9, 17), | |
] | |
lines_top = [ | |
(N, STAT, 9, 13.2), | |
(N, ALLSTAT, 6, 16.5), | |
] | |
prime_lines_occult_accessory = [ | |
(P, STAT, 6, 9), | |
(P, ALLSTAT, 3, 18), | |
] | |
lines_occult_accessory = [ | |
(N, STAT, 3, 21), | |
] | |
def filter_impossible_lines(combos): | |
for combo in combos: | |
counts = {BOSS: 0, IED: 0} | |
for (_, t, _, _) in combo: | |
if t in counts: | |
counts[t] += 1 | |
for x in counts.values(): | |
if x > 2: | |
break | |
else: | |
yield combo | |
def cube_calc( | |
text, prime_lines, lines, print_combos, singular_cube=False, prime_chance_singular=[] | |
): | |
print(f" {text} ".center(80, "=")) | |
lines = lines + prime_lines | |
def make_any_line(lines): | |
return lines + [(N, ANY, 0, 1.0/(1.0 - sum((1.0/onein for (_, _, _, onein) in lines))))] | |
# to represent all the lines we don't care about I generate an ANY line that | |
# has 1-(sum of the chances of all lines we care about) chance | |
p = make_any_line(prime_lines) | |
n = make_any_line(lines) | |
if not singular_cube: | |
combos_red = list(filter_impossible_lines(product(p, n, n))) | |
combos_violet = list(filter_impossible_lines(product(p, n, n, n, n, n))) | |
combos_equality = list(filter_impossible_lines(product(p, p, p))) | |
else: | |
combos_singular_cube = list(product(p, n, n)) | |
def combo_chance(want, prime_chance, combos): | |
good=set() | |
for combo in combos: | |
amounts = {} | |
for (prime, typ, amount, onein) in combo: | |
if typ not in amounts: amounts[typ] = 0 | |
amounts[typ] += amount | |
if ALLSTAT in amounts and STAT in amounts: | |
amounts[STAT] += amounts[ALLSTAT] | |
for k in want.keys(): | |
if k not in amounts or amounts[k] < want[k]: | |
break | |
else: | |
good.add(combo) | |
return sum([reduce(mul, [1.0/onein * (prime_chance[i] if prime else 1) | |
for i, (prime, typ, amount, onein) in enumerate(combo)]) for combo in good]) | |
def fmt_chance(text, wants, prime_chance, combos): | |
chance = sum([combo_chance(want, prime_chance, combos) for want in wants]) | |
return (text, f"1 in {round(1.0/chance)} cubes, {chance*100:.4f}%") | |
def tabulate(rows): | |
max_len = max((len(text) for (text, _) in rows)) | |
for (text, result) in rows: | |
print(f"{text.rjust(max_len)} {result}") | |
if singular_cube: | |
tabulate([fmt_chance(text, want, prime_chance_singular, combos_singular_cube) | |
for (text, want) in print_combos]) | |
return | |
print("red") | |
tabulate([fmt_chance(text, want, prime_chance_red, combos_red) | |
for (text, want) in print_combos]) | |
print() | |
print("violet") | |
tabulate([fmt_chance(text, want, prime_chance_violet, combos_violet) | |
for (text, want) in print_combos]) | |
print() | |
print("equality") | |
tabulate([fmt_chance(text, want, prime_chance_equality, combos_equality) | |
for (text, want) in print_combos]) | |
print() | |
print("black") | |
tabulate([fmt_chance(text, want, prime_chance_black, combos_red) | |
for (text, want) in print_combos]) | |
print() | |
def cube_calc_b(text, prime_lines, lines, print_combos): | |
return cube_calc(text, prime_lines, lines, print_combos, True, prime_chance_bonus) | |
def cube_calc_o(text, prime_lines, lines, print_combos): | |
return cube_calc(text, prime_lines, lines, print_combos, True, prime_chance_occult) | |
combos_ws = [ | |
("21+ att", [{ATT: 21}]), | |
("30+ att", [{ATT: 30}]), | |
("33+ att", [{ATT: 33}]), | |
("21+ att and boss", [{ATT: 21, BOSS: 1}]), | |
("21+ att and ied", [{ATT: 21, IED: 1}]), | |
("18+ att and 30+boss", [{ATT: 18, BOSS: 30}]), | |
("18+ att and 30+ied", [{ATT: 18, IED: 30}]), | |
("60+ied", [{IED: 60}]), | |
("70+ied", [{IED: 70}]), | |
("60+ied and att", [{IED: 60, ATT: 1}]), | |
("60+ied and boss", [{IED: 60, BOSS: 1}]), | |
("21+ att and boss or 18+att and 30+boss", [{ATT: 21, BOSS: 1}, {ATT: 18, BOSS: 30}]), | |
] | |
combos_e = [ | |
("21+ att", [{ATT: 21}]), | |
("30+ att", [{ATT: 30}]), | |
("33+ att", [{ATT: 33}]), | |
("21+ att and ied", [{ATT: 21, IED: 1}]), | |
] | |
combos_wse_b = [ | |
("18+ att", [{ATT: 18}]), | |
("21+ att", [{ATT: 21}]), | |
("30+ att", [{ATT: 30}]), | |
("33+ att", [{ATT: 33}]), | |
] | |
combos_stat = [ | |
("18+ stat", [{STAT: 18}]), | |
("21+ stat", [{STAT: 21}]), | |
("30+ stat", [{STAT: 30}]), | |
("33+ stat", [{STAT: 33}]), | |
("12+ all stat", [{ALLSTAT: 12}]), | |
("15+ all stat", [{ALLSTAT: 15}]), | |
("21+ all stat", [{ALLSTAT: 21}]), | |
] | |
combos_occult_stat = [ | |
("6+ stat", [{STAT: 6}]), | |
("9+ stat", [{STAT: 9}]), | |
("12+ stat", [{STAT: 12}]), | |
("3+ all stat", [{ALLSTAT: 3}]), | |
("6+ all stat", [{ALLSTAT: 6}]), | |
] | |
cube_calc("weapon", prime_lines_weapon, lines_weapon, combos_ws) | |
cube_calc("secondary", prime_lines_secondary, lines_secondary, combos_ws) | |
cube_calc("emblem", prime_lines_emblem, lines_emblem, combos_e) | |
cube_calc_b("weapon bpot", prime_lines_weapon_b, lines_weapon_b, combos_wse_b) | |
cube_calc_b("secondary bpot", prime_lines_secondary_b, lines_secondary_b, combos_wse_b) | |
cube_calc_b("emblem bpot", prime_lines_emblem_b, lines_emblem_b, combos_wse_b) | |
cube_calc("top/overall", prime_lines_top, lines_top, combos_stat) | |
cube_calc_o("accessory (occult cubes)", | |
prime_lines_occult_accessory, lines_occult_accessory, combos_occult_stat) |
This file contains hidden or 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
==================================== weapon ==================================== | |
red | |
21+ att 1 in 192 cubes, 0.5213% | |
30+ att 1 in 3909 cubes, 0.0256% | |
33+ att 1 in 54414 cubes, 0.0018% | |
21+ att and boss 1 in 1656 cubes, 0.0604% | |
21+ att and ied 1 in 1764 cubes, 0.0567% | |
18+ att and 30+boss 1 in 760 cubes, 0.1316% | |
18+ att and 30+ied 1 in 960 cubes, 0.1042% | |
60+ied 1 in 69 cubes, 1.4573% | |
70+ied 1 in 184 cubes, 0.5430% | |
60+ied and att 1 in 749 cubes, 0.1335% | |
60+ied and boss 1 in 511 cubes, 0.1958% | |
21+ att and boss or 18+att and 30+boss 1 in 521 cubes, 0.1920% | |
violet | |
21+ att 1 in 161 cubes, 0.6218% | |
30+ att 1 in 1014 cubes, 0.0986% | |
33+ att 1 in 4754 cubes, 0.0210% | |
21+ att and boss 1 in 435 cubes, 0.2297% | |
21+ att and ied 1 in 463 cubes, 0.2160% | |
18+ att and 30+boss 1 in 133 cubes, 0.7494% | |
18+ att and 30+ied 1 in 146 cubes, 0.6847% | |
60+ied 1 in 51 cubes, 1.9601% | |
70+ied 1 in 243 cubes, 0.4117% | |
60+ied and att 1 in 145 cubes, 0.6873% | |
60+ied and boss 1 in 124 cubes, 0.8065% | |
21+ att and boss or 18+att and 30+boss 1 in 102 cubes, 0.9791% | |
equality | |
21+ att 1 in 145 cubes, 0.6906% | |
30+ att 1 in 8615 cubes, 0.0116% | |
33+ att 1 in 8615 cubes, 0.0116% | |
21+ att and boss 1 in 957 cubes, 0.1045% | |
21+ att and ied 1 in 1436 cubes, 0.0696% | |
18+ att and 30+boss 1 in 957 cubes, 0.1045% | |
18+ att and 30+ied 1 in 1436 cubes, 0.0696% | |
60+ied 1 in 39 cubes, 2.5769% | |
70+ied 1 in 39 cubes, 2.5769% | |
60+ied and att 1 in 718 cubes, 0.1393% | |
60+ied and boss 1 in 239 cubes, 0.4179% | |
21+ att and boss or 18+att and 30+boss 1 in 479 cubes, 0.2089% | |
black | |
21+ att 1 in 165 cubes, 0.6050% | |
30+ att 1 in 3570 cubes, 0.0280% | |
33+ att 1 in 23439 cubes, 0.0043% | |
21+ att and boss 1 in 1289 cubes, 0.0776% | |
21+ att and ied 1 in 1451 cubes, 0.0689% | |
18+ att and 30+boss 1 in 672 cubes, 0.1488% | |
18+ att and 30+ied 1 in 859 cubes, 0.1164% | |
60+ied 1 in 60 cubes, 1.6579% | |
70+ied 1 in 145 cubes, 0.6913% | |
60+ied and att 1 in 652 cubes, 0.1533% | |
60+ied and boss 1 in 422 cubes, 0.2368% | |
21+ att and boss or 18+att and 30+boss 1 in 442 cubes, 0.2264% | |
================================== secondary =================================== | |
red | |
21+ att 1 in 247 cubes, 0.4054% | |
30+ att 1 in 6288 cubes, 0.0159% | |
33+ att 1 in 84790 cubes, 0.0012% | |
21+ att and boss 1 in 2651 cubes, 0.0377% | |
21+ att and ied 1 in 2829 cubes, 0.0354% | |
18+ att and 30+boss 1 in 1221 cubes, 0.0819% | |
18+ att and 30+ied 1 in 1543 cubes, 0.0648% | |
60+ied 1 in 89 cubes, 1.1186% | |
70+ied 1 in 233 cubes, 0.4288% | |
60+ied and att 1 in 1204 cubes, 0.0831% | |
60+ied and boss 1 in 819 cubes, 0.1221% | |
21+ att and boss or 18+att and 30+boss 1 in 836 cubes, 0.1196% | |
violet | |
21+ att 1 in 185 cubes, 0.5408% | |
30+ att 1 in 1393 cubes, 0.0718% | |
33+ att 1 in 7704 cubes, 0.0130% | |
21+ att and boss 1 in 598 cubes, 0.1673% | |
21+ att and ied 1 in 636 cubes, 0.1573% | |
18+ att and 30+boss 1 in 180 cubes, 0.5566% | |
18+ att and 30+ied 1 in 199 cubes, 0.5038% | |
60+ied 1 in 55 cubes, 1.8107% | |
70+ied 1 in 250 cubes, 0.4000% | |
60+ied and att 1 in 192 cubes, 0.5197% | |
60+ied and boss 1 in 161 cubes, 0.6227% | |
21+ att and boss or 18+att and 30+boss 1 in 138 cubes, 0.7239% | |
equality | |
21+ att 1 in 189 cubes, 0.5278% | |
30+ att 1 in 12978 cubes, 0.0077% | |
33+ att 1 in 12978 cubes, 0.0077% | |
21+ att and boss 1 in 1442 cubes, 0.0693% | |
21+ att and ied 1 in 2163 cubes, 0.0462% | |
18+ att and 30+boss 1 in 1442 cubes, 0.0693% | |
18+ att and 30+ied 1 in 2163 cubes, 0.0462% | |
60+ied 1 in 50 cubes, 1.9880% | |
70+ied 1 in 50 cubes, 1.9880% | |
60+ied and att 1 in 1081 cubes, 0.0925% | |
60+ied and boss 1 in 360 cubes, 0.2774% | |
21+ att and boss or 18+att and 30+boss 1 in 721 cubes, 0.1387% | |
black | |
21+ att 1 in 214 cubes, 0.4676% | |
30+ att 1 in 5726 cubes, 0.0175% | |
33+ att 1 in 36497 cubes, 0.0027% | |
21+ att and boss 1 in 2050 cubes, 0.0488% | |
21+ att and ied 1 in 2313 cubes, 0.0432% | |
18+ att and 30+boss 1 in 1076 cubes, 0.0930% | |
18+ att and 30+ied 1 in 1376 cubes, 0.0727% | |
60+ied 1 in 79 cubes, 1.2724% | |
70+ied 1 in 184 cubes, 0.5445% | |
60+ied and att 1 in 1043 cubes, 0.0958% | |
60+ied and boss 1 in 674 cubes, 0.1485% | |
21+ att and boss or 18+att and 30+boss 1 in 706 cubes, 0.1417% | |
==================================== emblem ==================================== | |
red | |
21+ att 1 in 132 cubes, 0.7581% | |
30+ att 1 in 2869 cubes, 0.0349% | |
33+ att 1 in 36866 cubes, 0.0027% | |
21+ att and ied 1 in 1284 cubes, 0.0779% | |
violet | |
21+ att 1 in 75 cubes, 1.3280% | |
30+ att 1 in 490 cubes, 0.2042% | |
33+ att 1 in 2501 cubes, 0.0400% | |
21+ att and ied 1 in 225 cubes, 0.4450% | |
equality | |
21+ att 1 in 106 cubes, 0.9423% | |
30+ att 1 in 5359 cubes, 0.0187% | |
33+ att 1 in 5359 cubes, 0.0187% | |
21+ att and ied 1 in 893 cubes, 0.1120% | |
black | |
21+ att 1 in 116 cubes, 0.8630% | |
30+ att 1 in 2601 cubes, 0.0385% | |
33+ att 1 in 15850 cubes, 0.0063% | |
21+ att and ied 1 in 1041 cubes, 0.0960% | |
================================= weapon bpot ================================== | |
18+ att 1 in 154 cubes, 0.6515% | |
21+ att 1 in 224 cubes, 0.4462% | |
30+ att 1 in 8916 cubes, 0.0112% | |
33+ att 1 in 819398 cubes, 0.0001% | |
================================ secondary bpot ================================ | |
18+ att 1 in 158 cubes, 0.6313% | |
21+ att 1 in 235 cubes, 0.4255% | |
30+ att 1 in 9378 cubes, 0.0107% | |
33+ att 1 in 905715 cubes, 0.0001% | |
================================= emblem bpot ================================== | |
18+ att 1 in 146 cubes, 0.6827% | |
21+ att 1 in 214 cubes, 0.4679% | |
30+ att 1 in 8288 cubes, 0.0121% | |
33+ att 1 in 759821 cubes, 0.0001% | |
================================= top/overall ================================== | |
red | |
18+ stat 1 in 36 cubes, 2.7910% | |
21+ stat 1 in 99 cubes, 1.0100% | |
30+ stat 1 in 2229 cubes, 0.0449% | |
33+ stat 1 in 33728 cubes, 0.0030% | |
12+ all stat 1 in 97 cubes, 1.0264% | |
15+ all stat 1 in 147 cubes, 0.6807% | |
21+ all stat 1 in 4178 cubes, 0.0239% | |
violet | |
18+ stat 1 in 14 cubes, 7.0205% | |
21+ stat 1 in 29 cubes, 3.4058% | |
30+ stat 1 in 196 cubes, 0.5107% | |
33+ stat 1 in 421 cubes, 0.2375% | |
12+ all stat 1 in 30 cubes, 3.2841% | |
15+ all stat 1 in 74 cubes, 1.3468% | |
21+ all stat 1 in 593 cubes, 0.1686% | |
equality | |
18+ stat 1 in 35 cubes, 2.8903% | |
21+ stat 1 in 35 cubes, 2.8903% | |
30+ stat 1 in 702 cubes, 0.1425% | |
33+ stat 1 in 1228 cubes, 0.0814% | |
12+ all stat 1 in 100 cubes, 0.9974% | |
15+ all stat 1 in 100 cubes, 0.9974% | |
21+ all stat 1 in 4913 cubes, 0.0204% | |
black | |
18+ stat 1 in 32 cubes, 3.0866% | |
21+ stat 1 in 83 cubes, 1.2065% | |
30+ stat 1 in 1664 cubes, 0.0601% | |
33+ stat 1 in 13573 cubes, 0.0074% | |
12+ all stat 1 in 89 cubes, 1.1225% | |
15+ all stat 1 in 129 cubes, 0.7768% | |
21+ all stat 1 in 3696 cubes, 0.0271% | |
=========================== accessory (occult cubes) =========================== | |
6+ stat 1 in 12 cubes, 8.5318% | |
9+ stat 1 in 109 cubes, 0.9192% | |
12+ stat 1 in 2133 cubes, 0.0469% | |
3+ all stat 1 in 25 cubes, 3.9600% | |
6+ all stat 1 in 19493 cubes, 0.0051% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment