biuuu / genshin-wish-export

Easily export the Genshin Impact wish record.
MIT License
3.76k stars 398 forks source link

建议增加一个统计歪/不歪多少次的功能 #215

Open SupppRabit opened 1 year ago

SupppRabit commented 1 year ago

逻辑大概是这样

from json import load
from time import strptime

#以下出现在限定池up里,但实际是常驻角色
temp2const = {'刻晴': ('2021-02-17 18:00:00', '2021-03-02 15:59:59'),
              '提纳里': ('2022-08-24 7:00:00', '2022-09-09 17:59:00'),
              '迪希雅': ('2023-03-01 7:00:00', '2023-03-21 17:59:00'),
              }
#常驻
consts = {'迪卢克', '琴', '刻晴', '莫娜', '七七', '提纳里', '迪希雅'}

#此次抽到的角色是否属于限定池中特殊up的常驻角色
def timehit(name, this_time):
    if name not in temp2const:
        return False
    this_time = strptime(this_time, "%Y-%m-%d %H:%M:%S")
    times_start = strptime(temp2const[name][0], "%Y-%m-%d %H:%M:%S")
    times_end = strptime(temp2const[name][1], "%Y-%m-%d %H:%M:%S")
    if times_start <= this_time <= times_end:
        return True
    return False

#userdata里保存的json记录
with open('gacha-list.json', 'r', encoding='utf-8') as f:
    record_json = load(f)

record = record_json['result'][0][1]
record = list(filter(lambda l: l[3] == 5, record))

win_count = fail_count = 0
guarantee = False
for each in record:
    if each[1] in consts and not timehit(each[1], each[0]):
        fail_count += 1
        guarantee = True
    elif not guarantee:
        win_count += 1
    else:
        guarantee = False

print("不歪次数:{}\n歪的次数:{}\n小保底不歪概率:{}".format(win_count, fail_count, win_count / (fail_count + win_count)))
TheraNinjaCat commented 2 weeks ago

I think this could be very useful information to display, especially if it's able to take into account the new Captured Radience theory: https://www.reddit.com/r/Genshin_Impact/comments/1f5mfqf/the_new_cn_capturing_radiance_theory/. Previously this would have been a simple "guarantee" vs "50/50" output, which while interesting it's fairly easy to see based on the last 5* pulled, now it could make it much easier to see what the current odds are based on previous wins/losses.