[issue1704] possible bug in randint
Rich Marinaccio
report at bugs.python.org
Fri Dec 28 05:00:00 CET 2007
Rich Marinaccio added the comment:
I have been using python for Civilization IV map scripting, and I
believe I have found a small problem with the randint function. Once in
a blue moon, randint(a,b) returns b + 1, rather than a <= N <= b. I
have seen this behavior a few times. Here is the code I used to
determine this.
randIndex = PWRand.randint(0,len(preshuffle)-1)#PWRand calls randint
directly with these parameters
if randIndex < 0 or randIndex >= len(preshuffle):
raise ValueError, " bad index shuffling plot list randIndex=%(r)d
listLength=%(l)d, mapSize=%(s)d" % {"r":randIndex,"l":len
(preshuffle),"s":hm.mapWidth*hm.mapHeight}
#output is
ValueError: bad index shuffling plot list randIndex=1453
listLength=1453, mapSize=13824
according to the docs, the max randIndex should be listLength - 1
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1704>
__________________________________
More information about the Python-bugs-list
mailing list