mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
generalize choose's rng
This commit is contained in:
parent
71839729a8
commit
26f389594a
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user