自己写的Python程序模拟原神抽卡,问题很大,但不知道怎么解决,有人帮我看看吗

from random import *

def gacha(times):
    ifornotlist = []
    goldslist = []
    golds = 0
    chance = 0
    gachatimes = 0
    gacha2 = False
    while gachatimes <= int(times):
        gachatimes = gachatimes + 1
        realtimes = (gachatimes + 1 - golds) % 90
        if realtimes < 75:  #没保底
            chance = 6
        elif realtimes < 90:  #保底了
            chance = 6 + (realtimes - 74) * 60  #设定概率
        if realtimes == 0:
            chance = 1000

        c = randint(1, 1000)  # 随机数
        if c <= chance:
            gacha1 = True
            d = randint(1,2)
            if ifornotlist:
                if not ifornotlist[len(ifornotlist)-1]:
                    gacha2 = True
                    ifornotlist.append(gacha2)
                else:
                    if d == 1:
                        gacha2 = True
                        ifornotlist.append(gacha2)
                    else:
                        gacha2 = False
                        ifornotlist.append(gacha2)
            else:
                if d == 1:
                    gacha2 = True
                    ifornotlist.append(gacha2)
                else:
                    gacha2 = False
                    ifornotlist.append(gacha2)  #判断是否歪
        else:
            gacha1 = False  # 判定是否出金
        if gacha1:
            golds = golds + realtimes
            goldslist.append(realtimes)
        if gacha1 and gacha2:
            print(goldslist[len(goldslist)-1], "\033[33m有\033[0m")
        if gacha1 and gacha2 is False:
            print(goldslist[len(goldslist)-1], "\033[35m歪\033[0m")
        if gachatimes > int(times):
            break


gacha(1145)

gacha函数里的参数times预想的是抽卡次数,但不管调用的时候写多少次都会持续输出到程序结束为止;而且概率明显偏高,不知道有什么问题。

编译器:PyCharm Community Edition 2022.2.1

你可能感兴趣的:(python,开发语言)