Created
June 2, 2021 10:19
-
-
Save wagyourtail/12eb712273eb4f91728f674cb250c59c 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
import copy | |
class reforge: | |
def __init__(self, name, cd=None, str=None): | |
if str is None: | |
str = [0, 0, 0, 0, 0, 0] | |
if cd is None: | |
cd = [0, 0, 0, 0, 0, 0] | |
self.name = name | |
self.cd = cd | |
self.str = str | |
# I know I could skip some, but... | |
reforges = [ | |
reforge("Bizarre", | |
cd=[-1, -2, -2, -3, -5, -7], | |
str=[1, 2, 2, 3, 5, 7] | |
), | |
reforge("Itchy", | |
cd=[3, 4, 5, 7, 10, 15], | |
str=[1, 1, 1, 2, 3, 4] | |
), | |
reforge("Ominous", | |
cd=[1, 1, 1, 1, 1, 1], | |
str=[1, 1, 1, 2, 3, 4] | |
), | |
reforge("Pleasent"), | |
reforge("Pretty"), | |
reforge("Shiny"), | |
reforge("Simple", | |
cd=[1, 1, 1, 1, 1, 1], | |
str=[1, 1, 1, 1, 1, 1] | |
), | |
reforge("Strange", | |
cd=[1, 2, 0, 1, 7, 9], | |
str=[2, 1, -1, 3, 0, 4] | |
), | |
reforge("Vivid"), | |
reforge("Godly", | |
cd=[2, 2, 3, 4, 6, 8], | |
str=[1, 2, 3, 5, 7, 10] | |
), | |
reforge("Demonic", | |
str=[1, 2, 2, 3, 5, 7] | |
), | |
reforge("Forceful", | |
str=[4, 5, 7, 10, 15, 20] | |
), | |
reforge("Hurtful", | |
cd=[4, 5, 7, 10, 15, 20] | |
), | |
reforge("Keen"), | |
reforge("Strong", | |
cd=[1, 2, 3, 5, 8, 12], | |
str=[1, 2, 3, 5, 8, 12] | |
), | |
reforge("Superior", | |
cd=[2, 2, 2, 3, 3, 5], | |
str=[2, 3, 4, 5, 7, 10] | |
), | |
reforge("Unpleasent"), | |
reforge("Zealous", | |
cd=[1, 2, 2, 3, 5, 7], | |
str=[1, 2, 2, 3, 5, 7] | |
) | |
] | |
def getAdjustedStrengthCrit(talisman_reforges, base_str, base_crit): | |
strength = base_str | |
crit = base_crit | |
for level in range(6): | |
for reforge in talisman_reforges[level]: | |
strength += reforge.str[level] | |
crit += reforge.cd[level] | |
return strength, crit | |
def calcDamageScore(talisman_reforges, base_str, base_crit): | |
strength, crit = getAdjustedStrengthCrit(talisman_reforges, base_str, base_crit) | |
return damageCheck(strength, crit) | |
def damageCheck(strength, crit): | |
return (1 + strength / 100.0) * (1 + crit / 100.0) | |
def replaceReforgeAtLevel(level, old_reforge, new_reforge, reforges): | |
reforges_copy = copy.deepcopy(reforges) | |
for i in range(len(reforges[level])): | |
if reforges[level][i] == old_reforge: | |
reforges_copy[level][i] = new_reforge | |
break | |
return reforges_copy | |
def printReforges(talisman_reforges): | |
reforges = [list(map(lambda x: x.name, ref)) for ref in talismans_reforges] | |
levels = ["Common", "Uncommon", "Rare", "Epic", "Legendary", "Mythic"] | |
for level in range(6): | |
names = sorted(list(set(reforges[level])), key=lambda k: -reforges[level].count(k)) | |
print(levels[level], end=": ") | |
print(*[f"{reforges[level].count(name)}x {name}" for name in names], sep=", ") | |
if __name__ == "__main__": | |
print( | |
"Welcome to the talisman optimizer, by Wagyourtail \n\nthis is for accessory optimization your armor should already be set to a good reforge...\n\n") | |
print("input number of Common, Uncommon, Rare, Epic, Legendary and Mythic talismans, separated by spaces") | |
talismans = list(map(int, input().split())) | |
print("it may work better if you remove your gravity talisman for the next part\n") | |
print("input strength and crit with current talismans, armor, held sword, potions, seperated by spaces") | |
print("also add the strength bonus from bestiary for desired mob to the strength") | |
base_strength, base_crit = tuple(map(int, input().split())) | |
print("input weapon base damage, this is the number labeled \"Damage\" on the sword") | |
base_damage = int(input()) | |
print("input damage dealt (with crit duh) to desired mob") | |
dealt_damage = int(input()) | |
print( | |
"input the strength and crit damage numbers shown on NEU's reforge stats info tab (anvil tab in accessory bag screen) or add them up yourself") | |
reforge_strength, reforge_crit = tuple(map(int, input().split())) | |
print( | |
"now put the gravity talisman back... the extra strength it give's won't be used in the calculations, but it's reforge will be\n") | |
weighted_addative_multiplier = dealt_damage / ((base_damage + 5.0) * damageCheck(base_strength, base_crit)) | |
base_crit -= reforge_crit | |
base_strength -= reforge_strength | |
best_str = [reforges[0], reforges[0], reforges[0], reforges[0], reforges[0], reforges[0]] | |
for i in range(6): | |
for reforge in reforges[1:]: | |
if reforge.str[i] > best_str[i].str[i]: | |
best_str[i] = reforge | |
talismans_reforges = [[best_str[i]] * talismans[i] for i in range(6)] | |
oldDmg = calcDamageScore(talismans_reforges, base_strength, base_crit) | |
newDmg = oldDmg | |
# gradient ascent | |
while True: | |
newReforges = None | |
for reforge in reforges: | |
for level in range(6): | |
for old_reforge in set(talismans_reforges[level]): | |
testReforges = replaceReforgeAtLevel(level, old_reforge, reforge, talismans_reforges) | |
testDmg = calcDamageScore(testReforges, base_strength, base_crit) | |
if testDmg > newDmg: | |
newDmg = testDmg | |
newReforges = testReforges | |
if newReforges is not None: | |
talismans_reforges = newReforges | |
oldDmg = newDmg | |
else: | |
break | |
print("\n\ngradient ascent from all strength reforges,\nestimated* damage:", | |
(base_damage + 5) * newDmg * weighted_addative_multiplier) | |
expected_strength, expected_crit = getAdjustedStrengthCrit(talismans_reforges, base_strength, base_crit) | |
print("expected strength:", expected_strength) | |
print("expected crit:", expected_crit) | |
print() | |
printReforges(talismans_reforges) | |
best_crit = [reforges[0], reforges[0], reforges[0], reforges[0], reforges[0], reforges[0]] | |
for i in range(6): | |
for reforge in reforges[1:]: | |
if reforge.cd[i] > best_crit[i].cd[i]: | |
best_crit[i] = reforge | |
talismans_reforges = [[best_crit[i]] * talismans[i] for i in range(6)] | |
oldDmg = calcDamageScore(talismans_reforges, base_strength, base_crit) | |
newDmg = oldDmg | |
# gradient ascent | |
while True: | |
newReforges = None | |
for reforge in reforges: | |
for level in range(6): | |
for old_reforge in set(talismans_reforges[level]): | |
testReforges = replaceReforgeAtLevel(level, old_reforge, reforge, talismans_reforges) | |
testDmg = calcDamageScore(testReforges, base_strength, base_crit) | |
if testDmg > newDmg: | |
newDmg = testDmg | |
newReforges = testReforges | |
if newReforges is not None: | |
talismans_reforges = newReforges | |
oldDmg = newDmg | |
else: | |
break | |
print("\n\ngradient ascent from all crit-damage reforges,\nestimated* damage:", | |
(base_damage + 5) * newDmg * weighted_addative_multiplier) | |
expected_strength, expected_crit = getAdjustedStrengthCrit(talismans_reforges, base_strength, base_crit) | |
print("expected strength:", expected_strength) | |
print("expected crit:", expected_crit) | |
print() | |
printReforges(talismans_reforges) | |
print( | |
"\n * estimated damages are not completely accurate and may be a bit high due to how enchantments are really " | |
"calculated, if someone knows how to make this work better without giving the user too much extra work, " | |
"please tell") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment