generalize choose's rng

This commit is contained in:
Darren Ranalli 2003-09-04 00:53:08 +00:00
parent 71839729a8
commit 26f389594a

View File

@ -10,8 +10,8 @@ class WeightedChoice:
self.listOfLists = listOfLists
self.weightIndex = weightIndex
def choose(self):
roll = random.randrange(self.total)
def choose(self, rng=random):
roll = rng.randrange(self.total)
weight = self.weightIndex
for i in self.listOfLists:
roll -= i[weight]