Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # notnotmelon 10/17/19
- # talisman calcuator aka maximise the damage function with 11 inpus
- from math import *
- # The heruistic algoithm is a wip, don't use for now
- heruistic = False
- heruistic_weighting = [2, 10, 3, 2, 10]
- # This class is a bit confusing ngl
- # It defines one route of one rarity
- # For example, if you have 5 rare talisman than one possiblity for this class's data would be (1, 2, 3, 0, 0)
- # It's confusing since I use a seperate construct to define the route for all rarities
- # That seperate construct is actually just a list of these routes
- class route:
- def __init__(self, counts, rarity):
- self.counts = counts
- self.rarity = rarity
- self.rarity_str = ["common", "uncommon", "rare", "epic"][rarity]
- self.stats = [sum(talismans_raw[y][rarity][x] * counts[y] if talismans_raw[y][rarity] else 0 for y in range(5)) for x in range(3)]
- self.strength, self.crit_chance, self.crit_dmg = self.stats
- def __repr__(self):
- result = ""
- for name, c in zip(talismans.keys(), self.counts):
- if c > 0:
- result += "{} {} {}{}, ".format(c, name, self.rarity_str, "" if c == 1 else "s")
- return result[:-2]
- def strength(self):
- return self.stats[0]
- def crit_damage(self):
- return self.stats[2]
- def heruistic_weight(self):
- result = 0
- for x, y in zip(self.stats, heruistic_weighting):
- result += x * y
- return result
- def bump(lst, idx, x):
- lst = lst.copy()
- lst[idx] += x
- return lst
- def routes(count, size, rarity):
- main = []
- def helper(count, idx, current):
- if count == 0:
- main.append(current)
- elif idx == size - 1:
- main.append(bump(current, idx, count))
- else:
- if talismans_raw[idx][rarity]:
- helper(count - 1, idx, bump(current, idx, 1))
- helper(count, idx + 1, current)
- helper(count, 0, [0] * size)
- return [route(x, rarity) for x in main]
- def heruistic_filter(routes):
- sum = 0.0
- for route in routes:
- sum += route.heruistic_weight()
- average = sum / len(routes)
- return filter(lambda stat: route.heruistic_weight() > average, routes)
- # Format is (common X, unc X, rare X, epic X), with X substutied with (str, chance, crit dmg)
- # Areas with "None" have direct upgrades in other reforges
- talismans = {
- 'forceful': ((2, 0, 0), (4, 0, 0), (7, 0, 0), (10, 0, 0)),
- 'itchy': ((1, 0, 3), (2, 0, 5), (2, 0, 8), (3, 0, 12)),
- 'unpleasnt': ((0, 1, 1), None, (0, 3, 2), (0, 6, 3)),
- 'strong': (None, None, (4, 0, 4), (7, 0, 7)),
- 'godly': ((1, 1, 1), (2, 2, 2), (4, 2, 3), (7, 3, 6)),
- }
- talismans_raw = list(talismans.values())
- weapon_dmg = int(input("Put all your talismans away, make sure you don't have any potion effects, and use /sbmenu while holding your sword for accurate stats.\nWhat is your weapon's raw damage?"))
- (strength, chance, crit_dmg) = [int(input('What is your ' + stat + '?')) for stat in ['strength', 'crit chance', 'crit damage']]
- counts = [int(input('How many ' + rarity + ' talisman do you have?')) for rarity in ['common', 'uncommon', 'rare', 'epic']]
- combat = int(input('What is your combat level?'))
- crit_goal = int(input('Do you want 80 or 100 crit chance?')) - chance
- ench_modifer = int(input('''What is your mob specfic enchant modifer?
- Note: You can find this by adding your sword's sharpness level * 5 with the amount of extra damage from other enchantments.
- For example, if you are focusing on damaging endermen and you have sharpness V but also have ender slayer V1 then this value would be (V * 5) + (VI * 12) = 25 + 72 = 97''')) + combat * 4 + 25
- ench_modifer += (100 if input('Are you trying to oneshot lots of enemies or are you fighting a boss? (For first strike and execute) valid inputs are: ONESHOT or BOSS').lower() == 'oneshot' else 50)
- def raw_damage(bouns_str):
- return (5 + weapon_dmg + floor(strength + bouns_str) / 5) * (1 + (bouns_str + strength) / 100.0)
- def ench_damage(bouns_str):
- return raw_damage(bouns_str) * (1 + ench_modifer / 100.0)
- def damage(bouns_str, bonus_crit_dmg):
- return ench_damage(bouns_str) * (1 + (bonus_crit_dmg + crit_dmg) / 100.0)
- def final_damage(routes):
- return damage(routes[0].strength + routes[1].strength + routes[2].strength + routes[3].strength,
- routes[0].crit_dmg + routes[1].crit_dmg + routes[2].crit_dmg + routes[3].crit_dmg)
- if heruistic:
- route_set = [heruistic_filter(routes(counts[i], len(talismans), i)) for i in range(4)]
- else:
- route_set = [routes(counts[i], len(talismans), i) for i in range(4)]
- #all_routes_to_max_crit = [x for x in product(*route_set) if crit_goal == x[0].crit_chance + x[1].crit_chance + x[2].crit_chance + x[3].crit_chance]
- all_routes_to_max_crit = []
- progress = len(route_set[0])
- # This is the most time consuming part of the algorithim, it sifts through millions of possible routes and pulls out the few that manage to reach the crit goal
- for i, r1 in enumerate(route_set[0]):
- print(i * 100 // progress, "%")
- cc1 = r1.crit_chance
- for r2 in route_set[1]:
- cc2 = r2.crit_chance + cc1
- for r3 in route_set[2]:
- cc3 = r3.crit_chance + cc2
- for r4 in route_set[3]:
- if cc3 + r4.crit_chance == crit_goal:
- all_routes_to_max_crit.append([r1, r2, r3, r4])
- if len(all_routes_to_max_crit) == 0:
- print("There is no possible combination that reaches the desired crit chance, try to get more talismen or level up your combat skill")
- else:
- max1 = [0, None]
- max2 = [0, None]
- max3 = [0, None]
- for routes in all_routes_to_max_crit:
- d = final_damage(routes)
- if max1[0] < d:
- max3 = max2
- max2 = max1
- max1 = [d, routes]
- elif max2[0] < d:
- max3 = max2
- max2 = [d, routes]
- elif max3[0] < d:
- max3 = [d, routes]
- print("The 3 best sets of talisman reforges are:")
- print(*max1)
- print(*max2)
- print(*max3)
- print("\nUsing the current meta (itchy on rares, epics, and commons) (godly on uncommons until 80%cc) would give you:")
- cc_needed = crit_goal
- # You could either use all of your crit goal or all of your unc talismans
- unc_needed = counts[1] if counts[1] * 2 < crit_goal else counts[1] - ceil(crit_goal / 2)
- com_needed = min(counts[0], crit_goal - unc_needed * 2)
- meta_routes = [route((0, counts[0] - com_needed, 0, 0, com_needed), 0),
- route((0, counts[1] - unc_needed, 0, 0, unc_needed), 1),
- route((0, counts[2], 0, 0, 0), 2),
- route((0, counts[3], 0, 0, 0), 3)]
- print(final_damage(meta_routes), meta_routes)
- cc_boost = com_needed + unc_needed * 2
- if cc_boost != crit_goal:
- print("This setup would also only give ", cc_boost + chance, "% crit chance", sep = "")
- print("\nYou should be doing", damage(0, 0), "without any talismen")
- print("\nKeep in mind that zealous and godly are the exact same for common and uncommon talismen")
- # Yeah the current meta is trash lol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement