Entrance Rando¶
- class entrance_rando.ERPlacementState(world: World, coupled: bool)¶
Bases:
object
The state of an ongoing or completed entrance randomization
- collection_state: CollectionState¶
The CollectionState backing the entrance randomization logic
- connect(source_exit: Entrance, target_entrance: Entrance) tuple[list[Entrance], list[Entrance]] ¶
Connects a source exit to a target entrance in the graph, accounting for coupling
- Returns:
The newly placed exits and the dummy entrance(s) which were removed from the graph
- coupled: bool¶
Whether entrance randomization is operating in coupled mode
- pairings: list[tuple[str, str]]¶
A list of pairings of connected entrance names, of the form (source_exit, target_entrance)
- placements: list[Entrance]¶
The list of randomized Entrance objects which have been connected successfully
- class entrance_rando.EntranceLookup(rng: Random, coupled: bool, usable_exits: set[Entrance])¶
Bases:
object
- dead_ends: GroupLookup¶
- others: GroupLookup¶
- exception entrance_rando.EntranceRandomizationError¶
Bases:
RuntimeError
- entrance_rando.bake_target_group_lookup(world: World, get_target_groups: Callable[[int], list[int]]) dict[int, list[int]] ¶
Applies a transformation to all known entrance groups on randomizable exists to build a group lookup table.
- Parameters:
world – Your World instance
get_target_groups – Function to call that returns the groups that a specific group type is allowed to connect to
- entrance_rando.disconnect_entrance_for_randomization(entrance: Entrance, target_group: int | None = None, one_way_target_name: str | None = None) None ¶
Given an entrance in a “vanilla” region graph, splits that entrance to prepare it for randomization in randomize_entrances. This should be done after setting the type and group of the entrance. Because it attempts to meet strict entrance naming requirements for coupled mode, this function may produce unintuitive results when called only on a single entrance; it produces eventually-correct outputs only after calling it on all entrances.
- Parameters:
entrance – The entrance which will be disconnected in preparation for randomization.
target_group – The group to assign to the created ER target. If not specified, the group from the original entrance will be copied.
one_way_target_name – The name of the created ER target if entrance is one-way. This argument is required for one-way entrances and is ignored otherwise.
- entrance_rando.randomize_entrances(world: World, coupled: bool, target_group_lookup: dict[int, list[int]], preserve_group_order: bool = False, er_targets: list[Entrance] | None = None, exits: list[Entrance] | None = None, on_connect: Callable[[ERPlacementState, list[Entrance]], None] | None = None) ERPlacementState ¶
Randomizes Entrances for a single world in the multiworld.
- Parameters:
world – Your World instance
coupled – Whether connected entrances should be coupled to go in both directions
target_group_lookup – Map from each group to a list of the groups that it can be connect to. Every group used on an exit must be provided and must map to at least one other group. The default group is 0.
preserve_group_order – Whether the order of groupings should be preserved for the returned target_groups
er_targets – The list of ER targets (Entrance objects with no parent region) to use for randomization. Remember to be deterministic! If not provided, automatically discovers all valid targets in your world.
exits – The list of exits (Entrance objects with no target region) to use for randomization. Remember to be deterministic! If not provided, automatically discovers all valid exits in your world.
on_connect – A callback function which allows specifying side effects after a placement is completed successfully and the underlying collection state has been updated.