mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 04:33:04 -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.listOfLists = listOfLists
|
||||||
self.weightIndex = weightIndex
|
self.weightIndex = weightIndex
|
||||||
|
|
||||||
def choose(self):
|
def choose(self, rng=random):
|
||||||
roll = random.randrange(self.total)
|
roll = rng.randrange(self.total)
|
||||||
weight = self.weightIndex
|
weight = self.weightIndex
|
||||||
for i in self.listOfLists:
|
for i in self.listOfLists:
|
||||||
roll -= i[weight]
|
roll -= i[weight]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user