我已经能够在我的扑克程序中多次复制此错误,并尝试了各种不成功的解决方案。这是最新的:
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":
答案 0 :(得分:0)
检查betCheck+(10-handValue[1])
的值。从追溯来看,它是-8。
答案 1 :(得分:0)
此代码
randint(1,betCheck+(10-handValue[1]))
给你这个
randrange(1,-7,-8)
这意味着betCheck+(10-handValue[1])
正在给你-8
该范围根本不会给你任何数字,因为betCheck +(10-handValue [1]))是负数而范围无效
你需要检查设置betcheck和handvalue [1]的代码,看看为什么它如此负面