Core: Rename the missed slot_seeds. (#1432)

* Rename the missed slot_seeds.

* Fixed a threaded context random error.
This commit is contained in:
CaitSith2 2023-02-03 10:39:18 -08:00 committed by GitHub
parent 0817305d5b
commit 555a0da46d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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)]

View File

@ -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"