Guest User

arcpassive_sim_at

a guest
Jul 17th, 2024
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 11.75 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. import seaborn as sns
  4. import os
  5. import matplotlib
  6. import matplotlib.pyplot as plt
  7. plt.rc("font", family = "Malgun Gothic")
  8. sns.set(font="Malgun Gothic",
  9. rc={"axes.unicode_minus":False}, style='white')
  10. %matplotlib inline
  11.  
  12. evol_db = {
  13.     't2_limitbreak_1': [('evol_multiplier', lambda x: x + 0.1)],
  14.     't2_limitbreak_2': [('evol_multiplier', lambda x: x + 0.2)],
  15.     't2_limitbreak_3': [('evol_multiplier', lambda x: x + 0.3)],
  16.     't2_keen_sense_1': [('evol_multiplier', lambda x: x + 0.05), ('crit_rate', lambda x: x + 0.04)],
  17.     't2_keen_sense_2': [('evol_multiplier', lambda x: x + 0.1), ('crit_rate', lambda x: x + 0.08)],
  18.     't3_full_force_smite_1': [('evol_multiplier', lambda x: x + 0.02), ('crit_rate', lambda x: x + 0.12)],
  19.     't3_full_force_smite_2': [('evol_multiplier', lambda x: x + 0.04), ('crit_rate', lambda x: x + 0.24)],
  20.     't3_strike_2': [('crit_rate', lambda x: x + 0.2), ('crit_damage', lambda x: x + 0.32)],
  21.     't3_strike_2_nonba': [('crit_rate', lambda x: x + 0.2)],
  22.     't3_juggernaut_2': [('evol_multiplier', lambda x: x + 0.24)],
  23.     't3_juggernaut_1': [('evol_multiplier', lambda x: x + 0.12)],
  24.     't3_domination_1': [('evol_multiplier', lambda x: x + 0.08), ('cdr', lambda x: x + 0.05)],
  25.     't3_domination_2': [('evol_multiplier', lambda x: x + 0.16), ('cdr', lambda x: x + 0.1)],
  26.     't4_mana_forge': [('evol_multiplier', lambda x: x + 0.225)],
  27.     't4_standup_fight': [('evol_multiplier', lambda x: x + 0.21)],
  28.     't4_blunt_spike': [('evol_multiplier', lambda x: x + 0.15)],
  29. }
  30.  
  31. engravings_db = {
  32.     'stabilized': [('damage_multiplier', lambda x: x*1.17)],
  33.     'kbw': [('damage_multiplier', lambda x: x*0.98), ('crit_damage', lambda x: x + 0.52)],
  34.     'grudge': [('damage_multiplier', lambda x: x*1.21)],
  35.     'cd': [('damage_multiplier', lambda x: x*1.17)],
  36.     'manaregen': [('damage_multiplier', lambda x: x*1.16)],
  37.     'adrenaline': [('crit_rate', lambda x: x + 0.2), ('atk_multiplier', lambda x: x + 0.054)],
  38.     'pd': [('crit_rate', lambda x: x + 0.2), ('crit_damage', lambda x: x - 0.06)],
  39.     'raid_captain': [('damage_multiplier', lambda x: x*(1+0.4*0.48))],
  40.     'mass_increase': [('damage_multiplier', lambda x: x*1.19)],
  41.     'master_elixir': [('crit_rate', lambda x: x + 0.07), ('additional_damage_multiplier', lambda x: x + 0.085)],
  42.     'crit_elixir': [('crit_damage_mutiplier', lambda x: x*1.12)],
  43.     'critdam_elixir': [('crit_damage', lambda x: x + 0.07)],
  44.     'adddam_elixir': [('additional_damage_multiplier', lambda x: x + 0.031)],
  45.     'ambush_master': [('damage_multiplier', lambda x: x*1.226)],
  46.     'ambush_master_nonba': [('damage_multiplier', lambda x: x*1.076)],
  47. }
  48.  
  49. enlightment_db = {
  50.     'ew_ba': [('damage_multiplier', lambda x: x*1.16 * 1.06), ('crit_damage', lambda x: x + 0.08), ('crit_rate', lambda x: x + 0.24)],
  51.     'ew_nba': [('damage_multiplier', lambda x: x*1.16), ('crit_damage', lambda x: x + 0.08), ('crit_rate', lambda x: x + 0.24)],
  52.     'ew_synergy': [('crit_rate', lambda x: x + 0.1)],
  53.     'at_core_enchant': [('crit_rate', lambda x: x + 0.09)]
  54. }
  55.  
  56. class APassive():
  57.     def __init__(self, name):
  58.         self.name = name
  59.         self.atk_multiplier = 1.0
  60.         self.damage_multiplier = 1.0
  61.         self.crit_rate = 0.02 # support bracelet
  62.         self.crit_damage = 2.0
  63.         self.crit_damage_mutiplier = 1.0
  64.         self.crit_total_multiplier = 1.0
  65.         self.additional_damage_multiplier = 1.3 # weapon quality
  66.         self.evol_multiplier = 1.0 + 0.14 # support
  67.         self.spec_multiplier = 1.0
  68.         self.cdr = 0.24 # level 10 cdr gem
  69.         self.cdr_reduction_coefficient = 1.0
  70.        
  71.     def set_stat(self, crit_stat: int, spec_stat: int, swift_stat: int, spec_stat_coefficient: float):
  72.  
  73.         crit_stat_coefficient = 0.000357
  74.         swift_cdr_coefficient = 1/(46.57*100)        
  75.         self.crit_stat = crit_stat + 60
  76.         self.spec_stat = spec_stat + 60
  77.         self.swift_stat = swift_stat + 60
  78.         self.spec_multiplier = spec_stat_coefficient*(self.spec_stat) + 1.0
  79.         self.crit_rate = self.crit_rate + (self.crit_stat)*crit_stat_coefficient
  80.         self.cdr = self.cdr + (self.swift_stat)*swift_cdr_coefficient
  81.    
  82.     def back_attack(self, ba=bool):
  83.         if ba:
  84.             self.crit_rate += 0.1
  85.             self.damage_multiplier *= 1.05
  86.    
  87.     def set_engravings(self, engravings: list, engravings_db: dict):
  88.         self.engravings = engravings
  89.         for engraving in engravings:
  90.             for target_stat, effect_func in engravings_db[engraving]:
  91.                 attribute = getattr(self, target_stat)
  92.                 setattr(self, target_stat, effect_func(attribute))
  93.                
  94.     def set_enlightment(self, enlightments: list, enlightment_db: dict):    
  95.         self.enlightment = enlightments
  96.         for enlightment in enlightments:
  97.             for target_stat, effect_func in enlightment_db[enlightment]:
  98.                 attribute = getattr(self, target_stat)
  99.                 setattr(self, target_stat, effect_func(attribute))
  100.                
  101.     def set_evol(self, evol_nodes: list, evol_db: dict):
  102.         self.evol_nodes = evol_nodes
  103.         for evol_node in evol_nodes:
  104.             for target_stat, effect_func in evol_db[evol_node]:
  105.                 attribute = getattr(self, target_stat)
  106.                 setattr(self, target_stat, effect_func(attribute))
  107.                
  108.     def blunt_spike(self):
  109.         if self.crit_rate >= 0.8:
  110.             blunt_spike_evol_bonus = min(1.4*(self.crit_rate - 0.8), 0.55)
  111.             self.evol_multiplier += blunt_spike_evol_bonus
  112.             self.crit_rate = min(self.crit_rate, 0.8)
  113.            
  114.     def expected_dps(self):
  115.         self.crit_total_multiplier = (self.crit_rate)*self.crit_damage*self.crit_damage_mutiplier + (1-self.crit_rate)
  116.         self.total_damage = self.atk_multiplier * self.damage_multiplier * self.crit_total_multiplier * self.additional_damage_multiplier * self.evol_multiplier * self.spec_multiplier
  117.         self.total_dps = self.total_damage/(1-self.cdr*self.cdr_reduction_coefficient)
  118.        
  119.     def build_output_calc(self, target_attr_list):
  120.         result = {}
  121.         for attr in target_attr_list:
  122.             result[attr] = getattr(self, attr)
  123.         return result
  124.  
  125. target_attr_list = ['crit_stat', 'spec_stat', 'swift_stat', 'engravings', 'enlightment', 'evol_nodes',
  126.                     'evol_multiplier', 'damage_multiplier', 'crit_rate', 'crit_damage',
  127.                     'crit_damage_mutiplier', 'additional_damage_multiplier', 'atk_multiplier',
  128.                     'cdr', 'cdr_reduction_coefficient', 'total_damage', 'total_dps']
  129.                    
  130. spec_stat_coefficient = 0
  131. input_data = {
  132.     '뭉툭한가시_저받달인': {
  133.         'crit_base': 1500 + 100 + 160, 'spec_base': 0, 'swift_base': 500 + 100,
  134.         'spec_stat_coefficient': spec_stat_coefficient,
  135.         'engravings': ['grudge', 'raid_captain', 'mass_increase', 'cd', 'kbw', 'master_elixir', 'critdam_elixir'],
  136.         'enlightment': ['at_core_enchant'],
  137.         'evol_nodes': ['t2_limitbreak_3', 't3_full_force_smite_2', 't4_blunt_spike']},    
  138.     '뭉툭한가시_저받회심': {
  139.         'crit_base': 1500 + 100 + 160, 'spec_base': 0, 'swift_base': 500 + 100,
  140.         'spec_stat_coefficient': spec_stat_coefficient,
  141.         'engravings': ['grudge', 'raid_captain', 'mass_increase', 'cd', 'kbw', 'crit_elixir', 'adddam_elixir'],
  142.         'enlightment': ['at_core_enchant'],
  143.         'evol_nodes': ['t2_limitbreak_1', 't2_keen_sense_2', 't3_full_force_smite_2', 't4_blunt_spike']},  
  144.     '입식타격_아드회심': {
  145.         'crit_base': 1500 + 100 + 160, 'spec_base': 0, 'swift_base': 500 + 100,
  146.         'spec_stat_coefficient': spec_stat_coefficient,
  147.         'engravings': ['grudge', 'raid_captain', 'mass_increase', 'cd', 'kbw', 'crit_elixir', 'critdam_elixir'],
  148.         'enlightment': ['at_core_enchant'],
  149.         'evol_nodes': ['t2_limitbreak_3', 't3_full_force_smite_1', 't3_domination_1', 't4_standup_fight']},  
  150.     '파괴전차입식_저받': {
  151.         'crit_base': 1500 + 100 + 160, 'spec_base': 0, 'swift_base': 500 + 100,
  152.         'spec_stat_coefficient': spec_stat_coefficient,
  153.         'engravings': ['grudge', 'raid_captain', 'mass_increase', 'cd', 'kbw', 'crit_elixir', 'critdam_elixir'],
  154.         'enlightment': ['at_core_enchant'],
  155.         'evol_nodes': ['t2_limitbreak_3', 't3_full_force_smite_1', 't3_juggernaut_1', 't4_standup_fight']},  
  156.     '파괴전차뭉가_아드': {
  157.         'crit_base': 1500 + 100 + 160, 'spec_base': 0, 'swift_base': 500 + 100,
  158.         'spec_stat_coefficient': spec_stat_coefficient,
  159.         'engravings': ['grudge', 'raid_captain', 'mass_increase', 'adrenaline', 'kbw', 'crit_elixir', 'critdam_elixir'],
  160.         'enlightment': ['at_core_enchant'],
  161.         'evol_nodes': ['t2_limitbreak_1', 't2_keen_sense_2', 't3_juggernaut_2', 't4_blunt_spike']}
  162. }
  163.        
  164. output_data = {}
  165. target_attr_list = ['crit_stat', 'spec_stat', 'swift_stat', 'engravings', 'enlightment', 'evol_nodes',
  166.                     'evol_multiplier', 'damage_multiplier', 'crit_rate', 'crit_damage',
  167.                     'crit_damage_mutiplier', 'additional_damage_multiplier', 'atk_multiplier',
  168.                     'cdr', 'cdr_reduction_coefficient', 'total_damage', 'total_dps']
  169.                    
  170. for key in input_data.keys():
  171.     build = input_data[key]
  172.     model = APassive(key)
  173.     model.set_stat(crit_stat=build['crit_base'], spec_stat=build['spec_base'],
  174.                    swift_stat=build['swift_base'], spec_stat_coefficient=build['spec_stat_coefficient'])
  175.     model.back_attack(ba=True)
  176.     model.set_engravings(engravings=build['engravings'], engravings_db=engravings_db)
  177.     model.set_enlightment(enlightments=build['enlightment'], enlightment_db=enlightment_db)
  178.     model.set_evol(evol_nodes=build['evol_nodes'], evol_db=evol_db)
  179.     if 't4_blunt_spike' in build['evol_nodes']:
  180.         model.blunt_spike()
  181.     model.expected_dps()
  182.     output_data[key] = model.build_output_calc(target_attr_list)
  183.     output_data[key]['build'] = key
  184.    
  185. output_df = pd.DataFrame(output_data).transpose()
  186. output_df['damage_percentage'] = (output_df.total_damage / output_df.total_damage.min()).map(lambda x: round(x, 3))
  187. output_df['dps_percentage'] = (output_df.total_dps / output_df.total_dps.min()).map(lambda x: round(x, 3))
  188.  
  189. output_df_kr = output_df.copy()
  190. output_df_kr.columns = ['치', '특', '신', '각인', '깨달음', '진화', '진화형피해계수',
  191.                      '피해량증가계수', '치명타적중률', '치피', '치피뎀(회심)', '추가피해계수',
  192.                      '공격력계수', '쿨감', '쿨감감소율(미사용)', '사이클데미지계수', 'DPS계수', '빌드명',
  193.                      '사이클데미지퍼센트환산', 'DPS퍼센트환산']
  194. output_df_kr.to_excel('result.xlsx')
  195.  
  196. output_viz = output_df[['damage_percentage', 'dps_percentage', 'build']]
  197. output_viz.columns = ['데미지 배율', 'DPS 배율', '빌드']
  198.  
  199. fig, ax = plt.subplots(figsize=(8, 8))
  200. ax=sns.barplot(
  201.     data=pd.melt(output_viz, id_vars='빌드', value_vars=['데미지 배율', 'DPS 배율']),
  202.     x='variable', y='value', hue='빌드')
  203. ax.set_title('빌드별 데미지/DPS 비교')
  204. ax.set_ylabel('데미지 증가량 계수')
  205. ax.set_xlabel('변수')
  206. ax.legend(title='빌드')
  207. plt.tight_layout()
  208. for i in ax.containers:
  209.     ax.bar_label(i,)
  210. fig.savefig('passive_test/build_compare_at.png')
  211.  
  212. output_df_kr[['빌드명', '치', '특', '신', '진화형피해계수',
  213.               '피해량증가계수', '치명타적중률', '치피', '치피뎀(회심)', '추가피해계수',
  214.               '공격력계수', '쿨감', '사이클데미지계수', 'DPS계수',
  215.               '사이클데미지퍼센트환산', 'DPS퍼센트환산']].reset_index(drop=True).to_excel('result.xlsx')
  216.  
Advertisement
Add Comment
Please, Sign In to add comment