gpt4 book ai didi

python - Python-randint()返回空范围,崩溃错误

转载 作者:行者123 更新时间:2023-12-03 16:13:48 25 4
gpt4 key购买 nike

我已经能够在扑克程序中多次重复此错误,并尝试了各种失败的解决方案。这是最新的:

Traceback (most recent call last):
File "C:\Users\Pangloss\Desktop\tgchanpoker\poker.py", line 1868, in <module>
if __name__ == '__main__': main()
File "C:\Users\Pangloss\Desktop\tgchanpoker\poker.py", line 1866, in main
mainGame = Game(opponent)
File "C:\Users\Pangloss\Desktop\tgchanpoker\poker.py", line 1443, in __init__
if randint(1,betCheck+(10-handValue[1]))<5 or gameStage == "bettingStay":
File "C:\Python27\lib\random.py", line 241, in randint
return self.randrange(a, b+1)
File "C:\Python27\lib\random.py", line 217, in randrange
raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width)
ValueError: empty range for randrange() (1,-7, -8)

这是相关的代码:
                    handValue = checkHand(opponent.cards.cards)
if gameStage == "betting" or gameStage == "final" or gameStage == "finalresponding":
betCheck = 18-handValue[1]-round(betAmount/(setMax/5))+opponent.brashness
elif gameStage == "extendedFinal":
betCheck = 16-handValue[1]-round(betAmount/(setMax/5))+opponent.brashness-(pot/100)
else:
betCheck = 16-handValue[1]-round(betAmount/(setMax/5))+opponent.brashness
foldCheck = 16-handValue[1]-round(betAmount/(setMax/3))+opponent.brashness+(pot/100)
if randint(1,betCheck+(10-handValue[1]))<5 or gameStage == "bettingStay":

最佳答案

此代码

randint(1,betCheck+(10-handValue[1]))

给你这个
randrange(1,-7,-8)

这意味着 betCheck+(10-handValue[1])给您-8

该范围根本不会给您任何数字,因为betCheck +(10-handValue [1]))为负数,并且该范围无效

您需要检查设置betcheck和handvalue [1]的代码,以了解为什么它是如此负数

关于python - Python-randint()返回空范围,崩溃错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17584995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com