From 3c9c16de7a260a195505a99884a0d2b5a57ee343 Mon Sep 17 00:00:00 2001 From: spinerak Date: Fri, 14 Jun 2024 20:38:04 +0200 Subject: [PATCH] Removed nonlocal and pass arguments instead --- worlds/yachtdice/Rules.py | 2 ++ worlds/yachtdice/__init__.py | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index 51df560811..ecbfce599f 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -218,6 +218,7 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu def dice_simulation_fill_pool(state, options): """ Returns the feasible score that one can reach with the current state, options and difficulty. + This function is called with state being a list, during filling of item pool. """ categories, num_dice, num_rolls, fixed_mult, step_mult, expoints = extract_progression(state, "state_is_a_list", options) return ( @@ -230,6 +231,7 @@ def dice_simulation_fill_pool(state, options): def dice_simulation_state_change(state, player, options): """ Returns the feasible score that one can reach with the current state, options and difficulty. + This function is called with state being a AP state object, while doing access rules. """ if state.prog_items[player]["state_is_fresh"] == 0: diff --git a/worlds/yachtdice/__init__.py b/worlds/yachtdice/__init__.py index e6e79e76a9..645e140290 100644 --- a/worlds/yachtdice/__init__.py +++ b/worlds/yachtdice/__init__.py @@ -173,12 +173,7 @@ class YachtDiceWorld(World): multipliers_added = 0 items_added = 0 - def get_item_to_add(): - nonlocal weights - nonlocal extra_points_added - nonlocal multipliers_added - nonlocal items_added - + def get_item_to_add(weights, extra_points_added, multipliers_added, items_added): items_added += 1 all_items = self.itempool + self.precollected @@ -258,7 +253,7 @@ class YachtDiceWorld(World): # adding 17 items as a start seems like the smartest way to get close to 1000 points for _ in range(17): - self.itempool.append(get_item_to_add()) + self.itempool.append(get_item_to_add(weights, extra_points_added, multipliers_added, items_added)) score_in_logic = dice_simulation_fill_pool(self.itempool + self.precollected, self.options) @@ -272,7 +267,7 @@ class YachtDiceWorld(World): else: # Keep adding items until a score of 1000 is in logic while score_in_logic < 1000: - item_to_add = get_item_to_add() + item_to_add = get_item_to_add(weights, extra_points_added, multipliers_added, items_added) self.itempool.append(item_to_add) if item_to_add == "1 Point": score_in_logic += 1