From 555a0da46db95e9c15bc4fa023e1132624740c9d Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Fri, 3 Feb 2023 10:39:18 -0800 Subject: [PATCH] Core: Rename the missed slot_seeds. (#1432) * Rename the missed slot_seeds. * Fixed a threaded context random error. --- worlds/AutoWorld.py | 2 +- worlds/witness/__init__.py | 4 ++-- worlds/witness/hints.py | 16 ++++++++-------- worlds/zillion/__init__.py | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index 8d1619b8..d7547a3a 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -229,7 +229,7 @@ class World(metaclass=AutoWorldRegister): def generate_output(self, output_directory: str) -> None: """This method gets called from a threadpool, do not use world.random here. - If you need any last-second randomization, use MultiWorld.slot_seeds[slot] instead.""" + If you need any last-second randomization, use MultiWorld.per_slot_randoms[slot] instead.""" pass def fill_slot_data(self) -> Dict[str, Any]: # json of WebHostLib.models.Slot diff --git a/worlds/witness/__init__.py b/worlds/witness/__init__.py index da085444..5a288e0c 100644 --- a/worlds/witness/__init__.py +++ b/worlds/witness/__init__.py @@ -56,7 +56,7 @@ class WitnessWorld(World): def _get_slot_data(self): return { - 'seed': self.multiworld.random.randint(0, 1000000), + 'seed': self.multiworld.per_slot_randoms[self.player].randint(0, 1000000), 'victory_location': int(self.player_logic.VICTORY_LOCATION, 16), 'panelhex_to_id': self.locat.CHECK_PANELHEX_TO_ID, 'item_id_to_door_hexes': self.static_items.ITEM_ID_TO_DOOR_HEX_ALL, @@ -189,7 +189,7 @@ class WitnessWorld(World): if hint_amount != 0: generated_hints = make_hints(self.multiworld, self.player, hint_amount) - self.multiworld.slot_seeds[self.player].shuffle(audio_logs) + self.multiworld.per_slot_randoms[self.player].shuffle(audio_logs) duplicates = len(audio_logs) // hint_amount diff --git a/worlds/witness/hints.py b/worlds/witness/hints.py index 898bd4dc..baa6dd45 100644 --- a/worlds/witness/hints.py +++ b/worlds/witness/hints.py @@ -157,10 +157,10 @@ def get_priority_hint_items(multiworld: MultiWorld, player: int): if get_option_value(multiworld, player, "doors") >= 2: priority.add("Desert Laser") lasers.remove("Desert Laser") - priority.update(multiworld.slot_seeds[player].sample(lasers, 2)) + priority.update(multiworld.per_slot_randoms[player].sample(lasers, 2)) else: - priority.update(multiworld.slot_seeds[player].sample(lasers, 3)) + priority.update(multiworld.per_slot_randoms[player].sample(lasers, 3)) return priority @@ -262,19 +262,19 @@ def make_hints(multiworld: MultiWorld, player: int, hint_amount: int): else: hints.append((loc, "contains", item[0], item[2])) - multiworld.slot_seeds[player].shuffle(hints) # shuffle always hint order in case of low hint amount + multiworld.per_slot_randoms[player].shuffle(hints) # shuffle always hint order in case of low hint amount - next_random_hint_is_item = multiworld.slot_seeds[player].randint(0, 2) + next_random_hint_is_item = multiworld.per_slot_randoms[player].randint(0, 2) prog_items_in_this_world = sorted(list(prog_items_in_this_world)) locations_in_this_world = sorted(list(loc_in_this_world)) - multiworld.slot_seeds[player].shuffle(prog_items_in_this_world) - multiworld.slot_seeds[player].shuffle(locations_in_this_world) + multiworld.per_slot_randoms[player].shuffle(prog_items_in_this_world) + multiworld.per_slot_randoms[player].shuffle(locations_in_this_world) while len(hints) < hint_amount: if priority_hint_pairs: - loc = multiworld.slot_seeds[player].choice(list(priority_hint_pairs.keys())) + loc = multiworld.per_slot_randoms[player].choice(list(priority_hint_pairs.keys())) item = priority_hint_pairs[loc] del priority_hint_pairs[loc] @@ -301,4 +301,4 @@ def make_hints(multiworld: MultiWorld, player: int, hint_amount: int): def generate_joke_hints(multiworld: MultiWorld, player: int, amount: int): - return [(x, y, z, -1) for (x, y, z) in multiworld.slot_seeds[player].sample(joke_hints, amount)] + return [(x, y, z, -1) for (x, y, z) in multiworld.per_slot_randoms[player].sample(joke_hints, amount)] diff --git a/worlds/zillion/__init__.py b/worlds/zillion/__init__.py index bc82c480..63823e8c 100644 --- a/worlds/zillion/__init__.py +++ b/worlds/zillion/__init__.py @@ -343,7 +343,7 @@ class ZillionWorld(World): def generate_output(self, output_directory: str) -> None: """This method gets called from a threadpool, do not use world.random here. - If you need any last-second randomization, use MultiWorld.slot_seeds[slot] instead.""" + If you need any last-second randomization, use MultiWorld.per_slot_randoms[slot] instead.""" self.finalize_item_locations() assert self.zz_system.patcher, "didn't get patcher from generate_early"