Buckets:

download
raw
3.21 kB
from __future__ import annotations
import gc
from typing import TYPE_CHECKING
from randovania.generator.filler.filler_configuration import (
FillerConfiguration,
FillerPlayerResult,
FillerResults,
PlayerPool,
)
from randovania.generator.filler.filler_library import UnableToGenerate
from randovania.generator.filler.player_state import PlayerState
from randovania.generator.filler.retcon import retcon_playthrough_filler
from randovania.resolver import debug
if TYPE_CHECKING:
from collections.abc import Callable, Sequence
from random import Random
async def run_filler(
rng: Random,
player_pools: Sequence[PlayerPool],
world_names: list[str],
status_update: Callable[[str], None],
*,
disable_gc_during: bool = True,
) -> FillerResults:
"""
Runs the filler logic for the given configuration and item pool.
Returns a GamePatches with progression items and hints assigned, along with all items in the pool
that weren't assigned.
:param rng:
:param player_pools:
:param world_names:
:param status_update:
:param disable_gc_during: If true, we disable the GC before the filler and re-enable it after.
:return:
"""
player_states = []
for index, pool in enumerate(player_pools):
config = pool.configuration
status_update(f"Creating state for {world_names[index]}")
standard_pickups = list(pool.pickups)
rng.shuffle(standard_pickups)
graph, state = pool.game_generator.bootstrap.logic_bootstrap_graph(config, pool.game, pool.patches)
player_states.append(
PlayerState(
index=index,
name=world_names[index],
game_enum=pool.game.game,
graph=graph,
original_game=pool.game,
initial_state=state,
pickups_left=standard_pickups,
configuration=FillerConfiguration.from_configuration(config),
)
)
try:
# The GC is a significant amount of CPU time during the generation.
if disable_gc_during:
gc.disable()
filler_result, actions_log = retcon_playthrough_filler(rng, player_states, status_update=status_update)
except UnableToGenerate as e:
message = "{}\n\n{}".format(
str(e),
"\n\n".join(f"#### {player.name}\n{player.current_state_report()}" for player in player_states),
)
debug.debug_print(message)
raise UnableToGenerate(message) from e
finally:
if disable_gc_during:
gc.enable()
results = []
for player_pool, player_state, patches in zip(player_pools, player_states, filler_result, strict=True):
results.append(
FillerPlayerResult(
game=player_state.original_game,
patches=patches,
unassigned_pickups=player_state.pickups_left,
pool=player_pool,
hint_state=player_state.hint_state,
)
)
if any(pool.configuration.should_hide_generation_log() for pool in player_pools):
actions_log = ()
return FillerResults(results, actions_log)

Xet Storage Details

Size:
3.21 kB
·
Xet hash:
e487cdb2b640f3a0b79cb8e04c2bdabeb003efb25376ac31219dda2e166dd99f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.