Skip to content

Commit

Permalink
add artifacts calc example, organize code about artifacts, add genshi…
Browse files Browse the repository at this point in the history
…n artifacts data
  • Loading branch information
OneBST committed Mar 10, 2023
1 parent 7fe193b commit 31a1379
Show file tree
Hide file tree
Showing 10 changed files with 624 additions and 343 deletions.
3 changes: 2 additions & 1 deletion GGanalysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
from GGanalysis.distribution_1d import *
from GGanalysis.gacha_layers import *
from GGanalysis.basic_models import *
from GGanalysis.stationary_dist import *
from GGanalysis.stationary_dist import *
from GGanalysis.scored_item import *
45 changes: 24 additions & 21 deletions GGanalysis/games/arknights/gacha_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
'''

__all__ = [
'pity_6star',
'pity_5star',
'PITY_6STAR',
'PITY_5STAR',
'P_5STAR_AVG',
'common_6star',
'single_up_6star',
'dual_up_specific_6star',
Expand All @@ -24,25 +25,27 @@
]

# 设置六星概率递增表
pity_6star = np.zeros(100)
pity_6star[1:51] = 0.02
pity_6star[51:99] = np.arange(1, 49) * 0.02 + 0.02
pity_6star[99] = 1
PITY_6STAR = np.zeros(100)
PITY_6STAR[1:51] = 0.02
PITY_6STAR[51:99] = np.arange(1, 49) * 0.02 + 0.02
PITY_6STAR[99] = 1
# 设置五星概率递增表(五星保底会被六星挤掉,所以需要做一点近似)
pity_5star = np.zeros(42, dtype=float)
pity_5star[:16] = 0.08
pity_5star[16:21] = np.arange(1, 6) * 0.02 + 0.08
pity_5star[21:41] = np.arange(1, 21) * 0.04 + 0.18
pity_5star[41] = 1
PITY_5STAR = np.zeros(42, dtype=float)
PITY_5STAR[:16] = 0.08
PITY_5STAR[16:21] = np.arange(1, 6) * 0.02 + 0.08
PITY_5STAR[21:41] = np.arange(1, 21) * 0.04 + 0.18
PITY_5STAR[41] = 1
# 设置五星综合概率,用于近似计算
P_5STAR_AVG = 0.08948

# 获取普通六星
common_6star = PityModel(pity_6star)
common_6star = PityModel(PITY_6STAR)
# 获取单UP六星
single_up_6star = PityBernoulliModel(pity_6star, 1/2)
single_up_6star = PityBernoulliModel(PITY_6STAR, 1/2)
# 获取双UP六星中的特定六星
dual_up_specific_6star = PityBernoulliModel(pity_6star, 1/4)
dual_up_specific_6star = PityBernoulliModel(PITY_6STAR, 1/4)
# 获取限定UP六星中的限定六星
limited_up_6star = PityBernoulliModel(pity_6star, 0.35)
limited_up_6star = PityBernoulliModel(PITY_6STAR, 0.35)

# 方舟限定池同时获取限定六星及陪跑六星
class AK_Limit_Model(CommonGachaModel):
Expand All @@ -63,15 +66,15 @@ def _build_parameter_list(self, pull_state: int=0, up_guarantee: int=0) -> list:
]
return parameter_list
# 同时获取两个UP六星
both_up_6star = AK_Limit_Model(pity_6star, 0.7, collect_item=2)
both_up_6star = AK_Limit_Model(PITY_6STAR, 0.7, collect_item=2)

# 实际上五星综合概率为8.948% 但由于和概率上升相耦合,这里取公示的8%作为低值估算
# 五星公示概率为的8%,实际上综合概率为8.948% 这里按照综合概率近似计算
# 获取普通五星
common_5star = BernoulliGachaModel(0.08)
common_5star = BernoulliGachaModel(P_5STAR_AVG)
# 获取单UP五星
single_up_specific_5star = BernoulliGachaModel(0.08/2)
single_up_specific_5star = BernoulliGachaModel(P_5STAR_AVG/2)
# 获取双UP五星中的特定五星
dual_up_specific_5star = BernoulliGachaModel(0.08/2/2)
dual_up_specific_5star = BernoulliGachaModel(P_5STAR_AVG/2/2)
# 获取三UP五星中的特定五星
triple_up_specific_5star = BernoulliGachaModel(0.08/2/3)
triple_up_specific_5star = BernoulliGachaModel(P_5STAR_AVG/2/3)

2 changes: 1 addition & 1 deletion GGanalysis/games/genshin_impact/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .gacha_model import *
# from .artifact_model import *
from .artifact_model import *
122 changes: 120 additions & 2 deletions GGanalysis/games/genshin_impact/artifact_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
'''
原神圣遗物数值表
类型别名如下
数值生命值 hp
数值攻击力 atk
数值防御力 def
百分比生命值 hpp
百分比攻击力 atkp
百分比防御力 defp
元素精通 em
元素充能效率 er
暴击率 cr
暴击伤害 cd
治疗加成 hb
'''
ARTIFACT_TYPES = ['flower', 'plume', 'sands', 'goblet', 'circlet']

# 所有主词条掉落权重表
# 掉落权重取自 tesiacoil 的整理
# 主词条 https://wiki.biligame.com/ys/掉落系统学/常用数据#主词条
P_MAIN_STAT = {
'flower': {'hp': 1000},
'plume': {'atk': 1000},
'sands': {
'hpp': 1334,
'atkp': 1333,
'defp': 1333,
'em': 500,
'er': 500,
},
'goblet': {
'hpp': 770,
'atkp': 770,
'defp': 760,
'pyroDB': 200,
'electroDB': 200,
'cryoDB': 200,
'hydroD B': 200,
'dendroDB': 200,
'anemoDB': 200,
'geoDB': 200,
'physicalDB': 200,
'em': 100,
},
'circlet': {
'hpp': 1100,
'atkp': 1100,
'defp': 1100,
'cr': 500,
'cd': 500,
'hb': 500,
'em': 200,
}
}

# 所有副词条权重表
p_sub_stat = {
# 掉落权重取自 tesiacoil 的整理
# 副词条 https://wiki.biligame.com/ys/掉落系统学/常用数据#副词条
P_SUB_STAT = {
'hp': 150,
'atk': 150,
'def': 150,
Expand All @@ -13,7 +69,60 @@
'cd': 75,
}

test_weight = {
# 五星圣遗物不同来源多词条占比 https://genshin-impact.fandom.com/wiki/Loot_System/Artifact_Drop_Distribution
P_DROP_STATE = {
'domains_drop': 0.2,
'normal_boos_drop': 0.34,
'weekly_boss_drop': 0.34,
'converted_by_alchemy_table': 0.34,
}

# 五星圣遗物主词条满级时属性 https://genshin-impact.fandom.com/wiki/Artifact/Stats
MAIN_STAT_MAX = {
'hp': 4780,
'atk': 311,
'hpp': 0.466,
'atkp': 0.466,
'defp': 0.583,
'em': 186.5,
'er': 0.518,
'pyroDB': 0.466,
'electroDB': 0.466,
'cryoDB': 0.466,
'hydroD B': 0.466,
'dendroDB': 0.466,
'anemoDB': 0.466,
'geoDB': 0.466,
'physicalDB': 0.583,
'cr': 31.1,
'cd': 62.2,
'hb': 35.9,
}

# 五星副词条单次升级最大值
# 全部的精确值见 https://nga.178.com/read.php?tid=31774495
SUB_STAT_MAX = {
'hp': 298.75,
'atk': 19.45,
'def': 23.14,
'hpp': 0.0583,
'atkp': 0.0583,
'defp': 0.0729,
'em': 23.31 ,
'er': 0.0648,
'cr': 0.0389,
'cd': 0.0777,
}

# 圣遗物强化经验翻倍概率 https://wiki.biligame.com/ys/掉落系统学/常用数据#主词条
P_EXP_MULTI = {
'1': 0.9,
'2': 0.09,
'5': 0.01,
}

# 默认打分权重,这个值可以是 [0,1] 的浮点数
DEFAULT_STAT_SCORE = {
'hp': 0,
'atk': 0,
'def': 0,
Expand All @@ -24,4 +133,13 @@
'er': 0,
'cr': 1,
'cd': 1,
}

# 默认主属性选择
DEFAULT_MAIN_STAT = {
'flower': 'hp',
'plume': 'atk',
'sands': 'atkp',
'goblet': 'pyroDB',
'circlet': 'cr',
}
Loading

0 comments on commit 31a1379

Please sign in to comment.