From 9a4f497564821fa05fb9d9ffd77f3f8263658bce Mon Sep 17 00:00:00 2001 From: pepperpepperpepper Date: Mon, 30 Nov 2015 09:40:36 -0800 Subject: ok --- ricky/unused/weight.py | 57 -------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 ricky/unused/weight.py (limited to 'ricky/unused') 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()) -- cgit v1.2.3-70-g09d2