random - Python - randint() returns empty range, crashing error -
i've been able duplicate error multiple times in poker program , tried various unsuccessful solutions. here's latest:
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 randrange() (%d,%d, %d)" % (istart, istop, width) valueerror: empty range randrange() (1,-7, -8)
and here's relevant code:
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":
this code
randint(1,betcheck+(10-handvalue[1]))
is giving this
randrange(1,-7,-8)
this means betcheck+(10-handvalue[1])
giving -8
that range not give number @ all, because betcheck+(10-handvalue[1])) negative number , range invalid
you need examine code sets betcheck , handvalue[1] see why negative
Comments
Post a Comment