Browse Source

generalize choose's rng

Darren Ranalli 22 years ago
parent
commit
26f389594a
1 changed files with 2 additions and 2 deletions
  1. 2 2
      direct/src/directutil/WeightedChoice.py

+ 2 - 2
direct/src/directutil/WeightedChoice.py

@@ -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]