【萌新投稿】自学几个月Python制作的明日方舟寻访模拟器
很拙劣的程序。技术力不足,代码还有很多欠缺之处,希望大佬们多多指教!
卡池.py
# '0'和重复的元素只是为了控制概率
test = {
'six_up':['Aup','0'],
'five_up':['Bup','0'],
'six_stars':['A1','A2','A3'],
'five_stars':['B1','B2','B3'],
'four_stars':['C1','C2','C3','C4'],
'three_stars':['D1','D2','D3','D4','D5'],
}
# 这个池子没有up!
常驻 = {
'six_up':['0'],
'five_up':['0'],
'six_stars':['能天使','黑','安洁莉娜','银灰','莫斯提马','夜莺','星熊','陈',
'阿','煌','麦哲伦','赫拉格','斯卡蒂','塞雷娅','闪灵','艾雅法拉','伊芙利特',
'推进之王','刻俄柏','风笛','傀影','温蒂','早露','铃兰','棘刺','森蚺',
'史尔特尔','瑕光','泥岩','山','空弦','嵯峨','异客','凯尔希','夕','年',
'W','迷迭香','浊心斯卡蒂'],
'five_stars':['狮蝎','食铁兽','蓝毒','拉普兰德','幽灵鲨','德克萨斯','槐琥',
'赫默','红','白面鸮','空','吽','灰喉','布洛卡','苇草','送葬人','星极',
'格劳克斯','诗怀雅','夜魔','真理','初雪','崖心','守林人','普罗旺斯','可颂',
'雷蛇','临光','华法琳','梅尔','天火','陨星','白金','芙兰卡','凛冬','惊蛰',
'慑砂','巫恋','极境','石棉','月禾','莱恩哈特','断崖','蜜蜡','贾维','安哲拉',
'燧石','四月','奥斯塔','絮雨','卡夫卡','爱丽丝','乌有','熔泉'],
'four_stars':['安比尔','梅','红云','桃金娘','苏苏洛','格雷伊','猎蜂','阿消',
'地灵','深海色','古米','蛇屠箱','角峰','调香师','末药','暗索','砾','慕斯',
'霜叶','缠丸','杜宾','红豆','清道夫','白雪','流星','杰西卡','远山','夜烟',
'宴','刻刀','波登可','卡达','孑','酸糖','芳汀','泡泡','杰克','松果','豆苗'],
'three_stars':['芬','炎熔','月见夜','香草','史都华德','卡缇','米格鲁','斑点',
'空爆','梓兰','芙蓉','克洛丝','玫兰莎','翎羽','泡普卡','安赛尔'],
}
# '浊心斯卡蒂'和'凯尔希'占六星出率的70%,'W'在剩余出率中以5倍权值出率提升
# '赤冬'占五星出率的50%
深悼 = {
'six_up':['浊心斯卡蒂','凯尔希','浊心斯卡蒂','凯尔希','浊心斯卡蒂','凯尔希',
'浊心斯卡蒂','凯尔希','浊心斯卡蒂','凯尔希','浊心斯卡蒂','凯尔希',
'浊心斯卡蒂','凯尔希',
'0','0','0','0','0','0','0','0','0','0','0','0','0'],
'five_up':['赤冬','0'],
'six_stars':['能天使','推进之王','伊芙利特','艾雅法拉','安洁莉娜','闪灵',
'夜莺','星熊','塞雷娅','银灰','斯卡蒂','陈','黑','赫拉格','麦哲伦',
'莫斯提马','煌','阿','刻俄柏','风笛','傀影','温蒂','早露','铃兰','棘刺',
'森蚋','史尔特尔','瑕光','泥若','山','空弦','嵯峨','异客',
'W','W','W','W','W'],
'five_stars':['白面鸮','凛冬','德克萨斯','芙兰卡','拉普兰德','幽灵鲨','蓝毒',
'白金','陨星','天火','梅尔','赫默','华法琳','临光','红','雷蛇','可颂',
'普罗旺斯','守林人','崖心','初雪','真理','空','狮竭','食铁兽','夜魔',
'诗怀雅','格劳克斯','星极','送葬人','槐琥','苇草','布洛卡','灰喉','吽',
'惊蛰','慑砂','巫恋','极境','石棉','月禾','莱恩哈特','断崖','蜜蜡','贾维',
'安哲拉','燧石','四月','奥斯塔','絮雨','卡夫卡','爱丽丝','乌有','熔泉'],
'four_stars':['夜烟','远山','杰西卡','流星','白雪','清道夫','红豆','杜宾',
'缠丸','霜叶','慕斯','砾','暗索','末药','调香师','角峰','蛇屠箱','古米',
'深海色','地灵','阿消','猎蜂','格雷伊','苏苏洛','桃金娘','红云','梅',
'安比尔','宴','刻刀','波登可','卡达','孑','酸糖','芳汀','泡泡','杰克',
'松果','豆苗'],
'three_stars':['芬','香草','翎羽','玫兰莎','卡缇','米格鲁','克洛丝','炎熔',
'芙蓉','安赛尔','史都华德','梓兰','空爆','月见夜','班点','泡普卡'],
}
寻访模拟器
from random import randint
from time import sleep
import 卡池
# 一系列要用到的变量
result = []# 储存抽卡结果
dic = {}# 定义空字典以共享引用卡池的字典
six,five,four,three = 0,0,0,0# 用于判断各个星级出现的总数
n = 0# 用于判断六星概率提升
# 初始化源石数和合成玉数,选择卡池,展示概率
print("欢迎来到Allen抽卡模拟器!\n合成玉不足时,源石会自动转换成合成玉!(1源石=180合成玉)")
while 1:
try:
stone = input('请输入初始源石数:')
stone = int(stone)
jade = input('请输入初始合成玉数:')
jade = int(jade)
break
except:
print('请正确输入数值!')
while 1:
tip = input("请选择卡池(test/常驻/深悼):")
try:
dic = eval(f'卡池.{tip}')
break
except:
print("请正确选择卡池!")
# 将六星和五星分别整理到一个集合中,以便展示结果时使用
six_up_result = set(dic['six_up'])
six_up_result.remove('0')
five_up_result = set(dic['five_up'])
five_up_result.remove('0')
six_stars_result = set(dic['six_stars'])|six_up_result
five_stars_result = set(dic['five_stars'])|five_up_result
# 打印卡池
print(f"已选择卡池:{tip}\n六星(2%):",end='')
for i in six_stars_result:
print(i,end=',')
print("\n五星(8%):",end='')
for i in five_stars_result:
print(i,end=',')
print("\n四星(50%):",end='')
for i in dic['four_stars']:
print(i,end=',')
print("\n三星(40%):",end='')
for i in dic['three_stars']:
print(i,end=',')
print("\n")
def judge(n):
"""判断抽卡结果"""
global six,five,four,three# 定义全局变量
if n<=50:
num=50
else:
num=n# 判断抽卡次数
b = randint(1,1000)
if b>= 1 and b<= 20+(num-50)*20:# 六星
a = dic['six_up'][randint(0,int(len(dic['six_up']))-1)]
if a != '0':
result.append(a)
print(a)
else:
a = dic['six_stars'][randint(0,int(len(dic['six_stars']))-1)]
result.append(a)
print(a)
six+=1
n=0# 重置抽卡次数
elif b>=921 and b<=1000:# 五星
a = dic['five_up'][randint(0,int(len(dic['five_up']))-1)]
if a != '0':
result.append(a)
print(a)
else:
a = dic['five_stars'][randint(0,int(len(dic['five_stars']))-1)]
result.append(a)
print(a)
five+=1
n+=1
elif b>=421 and b<=920:# 四星
a = dic['four_stars'][randint(0,int(len(dic['four_stars']))-1)]
four+=1
n+=1
result.append(a)
print(a)
else:# 三星
a = dic['three_stars'][randint(0,int(len(dic['three_stars']))-1)]
three+=1
n+=1
result.append(a)
print(a)
def one():
"""单抽"""
judge(n)
def ten():
"""十连"""
for i in range(10):
# sleep(0.2)
one()
# 主程序部分
active = True
while active:
a = input(f"\n源石数:{stone} 合成玉数:{jade}\n输入1单抽,输入2十连:\n(输入'q'以退出)")
while a == '1':
if jade >= 600:# 判断合成玉是否足够
jade -= 600
one()
break
else:# 尝试将源石转换成合成玉
if stone >= 1:
stone -= 1
jade += 180
else:# 源石不足
break
while a == '2':
if jade >= 6000:# 判断合成玉是否足够
jade -= 6000
ten()
break
else:
if stone >= (6000-jade)/180:# 尝试将源石转换成合成玉
if (6000-jade)%180==0:# 当所需合成玉数能转换成整数颗源石时
stone -= int((6000-jade)/180)
jade = 6000
else:# 当所需合成玉数不能转换成整数颗源石时
stone -= int((6000-jade)//180+1)
jade += int(((6000-jade)//180+1)*180)
else:
print('源石不足!请单抽!')
break
if a == 'q':# 退出主程序
break
while stone*180+jade < 600:# 氪金系统
tip = input(f'\n源石数:{stone} 合成玉数:{jade}\n源石不足,是否氪金?(¥648=130源石)(y/n)')
if tip == 'y':# 确认氪金
stone += 130
print('氪金成功!')
if tip == 'n':# 取消氪金并退出主程序
active = False
break
# 抽卡结果展示
print(f'\n抽卡数:{len(result)}')
# 打印抽卡结果
print("六星:",end="")
for i in six_stars_result:
if i in result:# 判断抽卡结果
print(f"{i}:{str(result.count(i))}",end=" ")
print(f"总数:{six}")
print("五星:",end="")
for i in five_stars_result:
if i in result:# 判断抽卡结果
print(f"{i}:{str(result.count(i))}",end=" ")
print(f"总数:{five}")
print("四星:",end="")
for i in dic['four_stars']:
if i in result:# 判断抽卡结果
print(f"{i}:{str(result.count(i))}",end=" ")
print(f"总数:{four}")
print("三星:",end="")
for i in dic['three_stars']:
if i in result:# 判断抽卡结果
print(f"{i}:{str(result.count(i))}",end=" ")
# 打印总览
print(f"总数:{three}\n共消耗{len(result)}颗源石,价值{len(result)*180}合成玉!")
luck = six/len(result)
print(f"六星出货占比:{'%.3f'%luck}")
if float(luck) > 0.02:
print("双黄出货全满潜")
else:
print("醒来枕边泪点点")
print('\n已退出模拟器!')
如果程序有什么不足之处,请及时指出!
谢谢大佬们