This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cephalo
Recipients cephalo
Date 2007-12-28.03:58:42
SpamBayes Score 0.15442914
Marked as misclassified No
Message-id <1198814325.03.0.53847270276.issue1704@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2007-12-28 03:58:45cephalosetspambayes_score: 0.154429 -> 0.15442914
recipients: + cephalo
2007-12-28 03:58:45cephalosetspambayes_score: 0.154429 -> 0.154429
messageid: <1198814325.03.0.53847270276.issue1704@psf.upfronthosting.co.za>
2007-12-28 03:58:44cephalolinkissue1704 messages
2007-12-28 03:58:43cephalocreate