diff options
| author | pepperpepperpepper <pepper@scannerjammer.com> | 2015-11-30 09:40:36 -0800 |
|---|---|---|
| committer | pepperpepperpepper <pepper@scannerjammer.com> | 2015-11-30 09:40:36 -0800 |
| commit | 9a4f497564821fa05fb9d9ffd77f3f8263658bce (patch) | |
| tree | c9851ad823323aee2cf33f76095d6e435ea8aaa3 /ricky/unused | |
| parent | f3cfd54c876ba3e7540443c2f442d2baa22acef8 (diff) | |
ok
Diffstat (limited to 'ricky/unused')
| -rw-r--r-- | ricky/unused/weight.py | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/ricky/unused/weight.py b/ricky/unused/weight.py deleted file mode 100644 index 4bd4af4..0000000 --- a/ricky/unused/weight.py +++ /dev/null @@ -1,57 +0,0 @@ - weights_total = sum( - map(lambda x: x["weight"], self.probabilities()) - ) + (255 * 255 * 255) - choice = random.randint(0, weights_total) - position = 0 - for elem in self.probabilities(): - position += elem["weight"] - if position >= choice: - self.value = elem["value"] - return - - weights_total = sum( - map(lambda x: x["weight"], self.probabilities()) - )# + self.range_max - self.range_min - if weights_total < 100: - weights_total = 100; - choice = random.randint(0, weights_total) - import sys - sys.stderr.write("choosing %s: random_int: %s, probabilities: %s\n" % ( - self.name, - choice, - self.probabilities())) - position = 0 - for elem in self.probabilities(): - position += elem["weight"] - if position >= choice: - self.value = elem["value"] - return - - - weights_total = sum(map(lambda x: x["weight"], self.probabilities())) - choice = random.randint(0, weights_total) - position = 0 - for elem in self.probabilities(): - position += elem["weight"] - if position >= choice: - self.value = elem["value"] - break - def _choose_heaviest(self): - heaviest_idx = 0 - heaviest_weight = 0 - idx = 0 - if (len(self.options())): - for elem in self.options(): - if elem["weight"] > heaviest_weight: - heaviest_weight = elem["weight"] - heaviest_idx = idx - idx += 1 - return self.options()[heaviest_idx]["value"] - else: - self.randomize() - - def heaviest(self): - self.value = self._choose_heaviest() - - """default value is the probability with the heaviest weight""" - self.default(self._choose_heaviest()) |
