用Python简单模拟《原神》抽卡系统 您所在的位置:网站首页 原神抽卡代码手机怎么搞出来 用Python简单模拟《原神》抽卡系统

用Python简单模拟《原神》抽卡系统

2024-07-10 17:05| 来源: 网络整理| 查看: 265

原始代码参考自另一位博主的文章:

用Python简单模拟《原神》抽卡系统_抽卡系统怎么做出来的-CSDN博客

在其代码上修复了一些概率的小问题,以及增加了显示效果和统计。

效果如下

直接贴上code """ 要求:180抽大保底,90抽小保底 10抽必出4星 90抽必出5星 抽到的时候up和常驻各占50% P = { 0.006 i 小保底已垫了%d抽" % already_times) isGuarantees = get_isGuarantees() if isGuarantees: print(" -> 大保底在手,不慌~") else: print(" -> 没大保底,祝您出金不歪~") print("已抽卡%d次" % total_num) try: input_content = input('\n请输入抽数,退出请输入q\n请输入:') if input_content == 'q': print("\n抽卡统计:") print("本次总计抽卡%d次" % total_num) print("出(4星/5星)角色情况:") counts = dict(Counter(get_rare_roles)) print(counts) exit(0) else: count = int(input_content) total_num += count except ValueError: print('你这输入的啥玩意') continue round = [] for _ in range(count // 10): round.append(10) if count % 10: round.append(count % 10) for draws in round: fiveStar_num = 0 fourStar_num = 0 res_list = [[], [], []] # 第一个放金,第二个放紫,第三个放蓝 flag_up = False for _ in range(draws): rate_update(already_times) if (already_times==89 and already_rare==8 ) or already_rare >= 9: # 连续9 发没出紫,必出紫 character_rank = '紫' else: character_rank = random.choice(rate_list) already_times += 1 if character_rank == '蓝': role = random.choice(threeStar) res_list[2].append(f"{Fore.BLUE}{role}{Style.RESET_ALL}") already_rare += 1 elif character_rank == '紫': fourStar_role = random.choice(fourStar) if fourStar_isGuarantees: # 四星角色小保底:如果上一个出的不是up四星,下一次必出 role = random.choice(fourStar_up) fourStar_isGuarantees = False else: fourStar_isGuarantees = random.choice([True, False]) if fourStar_isGuarantees: role = random.choice(fourStar) else: role = random.choice(fourStar_up) get_rare_roles.append(role) res_list[1].append(f"{Fore.MAGENTA}{role}{Style.RESET_ALL}") fourStar_num += 1 already_rare = 0 elif character_rank == '金': rate_initialization() if guarantees(): role = up flag_up = True else: role = random.choice(fiveStar) get_rare_roles.insert(0, role) res_list[0].append(f"{Fore.YELLOW}{role}{Style.RESET_ALL}") fiveStar_num += 1 already_rare += 1 already_times = 0 # 垫卡次数清零 record_times(already_times) record_rare(already_rare) print("\n%d连抽出货情况:" % draws) print('==================================================') if fiveStar_num > 1: print("恭喜!%d连%d金!" %(draws, fiveStar_num)) elif fiveStar_num == 1: if flag_up: print("出货啦~") else: print("金色传...可惜歪了") elif fourStar_num > 0: print("%d紫" % fourStar_num) print(f' '.join(list(map(lambda x: f' '.join(x), res_list)))) print('==================================================') print(" ") UP角色

up.txt

就写一个限定角色就行,如:纳西妲

五星常驻

fiveStar.txt

刻晴 莫娜 七七 迪卢克 琴 迪希雅 提纳里

四星角色物品

fourStar.txt

香菱 行秋 班尼特 菲谢尔 鹿野院平藏 罗莎莉亚 芭芭拉 砂糖 凝光 柯莱 雷泽 重云 诺艾尔 云堇 五郎 九条裟罗 久岐忍 烟绯 辛焱 迪奥娜 早柚 北斗 托马 宗室大剑 祭礼大剑 西风大剑 黑岩斩刀 钟剑 白影剑 千岩古剑 西风剑 祭礼剑 笛剑 暗巷闪光 祭礼弓 破魔之弓 西风猎弓 绝弦 昭心 万国诸海图 西风秘典 流浪乐章 祭礼残章 千岩长枪 西风长枪

四星UP角色,一般是3个

夏洛蒂 北斗 柯莱

三星武器

threeStar.txt

就写了个蓝色,有兴趣的可以自己写一下

(记得在卡池里放东西,也就是上门这些txt文件)



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有