From 570af1ab4cd02308141b21d24654deed18ef39aa Mon Sep 17 00:00:00 2001 From: spinerak Date: Mon, 10 Jun 2024 19:36:55 +0200 Subject: [PATCH] change .random and used enumerate --- worlds/yachtdice/Rules.py | 6 +++--- worlds/yachtdice/__init__.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index 0afdfaa5b2..055b638f48 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -192,16 +192,16 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu # calculate total distribution total_dist = {0: 1} - for j in range(len(categories)): + for j, category in enumerate(categories): if num_dice == 0 or num_rolls == 0: dist = {0: 100000} else: - dist = yacht_weights[categories[j].name, min(8, num_dice), min(8, num_rolls)].copy() + dist = yacht_weights[category.name, min(8, num_dice), min(8, num_rolls)].copy() for key in dist.keys(): dist[key] /= 100000 - cat_mult = 2 ** (categories[j].quantity - 1) + cat_mult = 2 ** (category.quantity - 1) # for higher difficulties, the simulation gets multiple tries for categories. max_tries = j // diff_divide diff --git a/worlds/yachtdice/__init__.py b/worlds/yachtdice/__init__.py index fef7b31e81..47a1cc2ad2 100644 --- a/worlds/yachtdice/__init__.py +++ b/worlds/yachtdice/__init__.py @@ -79,7 +79,7 @@ class YachtDiceWorld(World): categorylist = [1] * num_ones + [0] * (16 - num_ones) # Shuffle the list to randomize the order - self.multiworld.random.shuffle(categorylist) + self.random.shuffle(categorylist) # A list of all possible categories. # Every entry in the list has two categories, one 'default' category and one 'alt'. @@ -207,7 +207,7 @@ class YachtDiceWorld(World): weights[5] = 1 # Next, add the appropriate item. We'll slightly alter weights to avoid too many of the same item - which_item_to_add = self.multiworld.random.choices([0, 1, 2, 3, 4, 5], weights=weights)[0] + which_item_to_add = self.random.choices([0, 1, 2, 3, 4, 5], weights=weights)[0] item_to_add = "" if which_item_to_add == 0: weights[0] /= 1 + frags_per_dice @@ -232,7 +232,7 @@ class YachtDiceWorld(World): elif which_item_to_add == 4: cat_weights = [2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1] weights[4] /= 1.1 - return self.multiworld.random.choices(possible_categories, weights=cat_weights)[0] + return self.random.choices(possible_categories, weights=cat_weights)[0] elif which_item_to_add == 5: score_dist = self.options.points_size.value probs = [1, 0, 0] @@ -244,7 +244,7 @@ class YachtDiceWorld(World): probs = [0, 0.3, 0.7] if score_dist == 4: probs = [0.3, 0.4, 0.3] - c = self.multiworld.random.choices([0, 1, 2], weights=probs)[0] + c = self.random.choices([0, 1, 2], weights=probs)[0] if c == 0: weights[5] /= 1.01 extra_points_added += 1 @@ -342,7 +342,7 @@ class YachtDiceWorld(World): # probability of Good and Bad rng, based on difficulty for fun :) p = 1.1 - 0.25 * self.options.game_difficulty.value already_items = len(self.itempool) + 1 - self.itempool += self.multiworld.random.choices( + self.itempool += self.random.choices( ["Good RNG", "Bad RNG"], weights=[p, 1 - p], k=self.number_of_locations - already_items )