mini_arcade_core.scenes.systems.builtins.maze¶
Reusable maze and lane-based grid gameplay helpers.
Classes¶
Four-way grid direction. |
|
Dense grid of maze/tile values. |
|
Mutable cell-based movement state for one maze agent. |
|
Declarative lane/junction navigation rule. |
|
Advance one or more maze agents through a tile map with turn buffering. |
|
Declarative horizontal/vertical wrap rule for maze agents. |
|
Wrap maze agents across configured grid edges. |
|
Common collectible kinds for maze games. |
|
Mutable collectible metadata stored inside a field. |
|
Dense collectible state keyed by grid cell. |
|
Declarative collectible pickup rule. |
|
Consume collectibles when a collector enters the same cell. |
|
One timed gameplay mode segment. |
|
Mutable state for timed mode progression. |
|
Declarative timed mode schedule. |
|
Advance timed mode schedules using the current frame dt. |
Functions¶
|
Return the adjacent cell in the given direction. |
|
Build a tile map from ASCII rows and a legend. |
|
Return the cardinal exits available from one cell. |
|
Choose the exit that minimizes Manhattan distance to a target cell. |
|
Choose the exit that maximizes Manhattan distance from a target cell. |
|
Choose one valid exit randomly. |
|
Return whether a cell exposes more than two valid exits. |
Module Contents¶
- class mini_arcade_core.scenes.systems.builtins.maze.CardinalDirection[source]¶
Bases:
str,enum.EnumFour-way grid direction.
- UP = 'up'¶
- DOWN = 'down'¶
- LEFT = 'left'¶
- RIGHT = 'right'¶
- property vector: tuple[int, int]¶
Return the (dcol, drow) vector for this direction.
- property opposite: CardinalDirection¶
Return the opposite cardinal direction.
- mini_arcade_core.scenes.systems.builtins.maze.step_in_direction(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, direction: CardinalDirection) mini_arcade_core.scenes.systems.builtins.grid.GridCoord[source]¶
Return the adjacent cell in the given direction.
- class mini_arcade_core.scenes.systems.builtins.maze.TileMap[source]¶
Bases:
Generic[TCell]Dense grid of maze/tile values.
- default: TCell | None = None¶
- contains(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord) bool[source]¶
Return whether a coordinate falls inside the tile-map bounds.
- get(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord) TCell | None[source]¶
Return the stored tile value at one coordinate, if in bounds.
- set(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, value: TCell | None) None[source]¶
Store a tile value at one coordinate.
- iter_cells() tuple[tuple[mini_arcade_core.scenes.systems.builtins.grid.GridCoord, TCell | None], Ellipsis][source]¶
Return all cells with their stored values.
- mini_arcade_core.scenes.systems.builtins.maze.tile_map_from_strings(*rows: str, legend: Mapping[str, TCell], default: TCell | None = None) TileMap[TCell][source]¶
Build a tile map from ASCII rows and a legend.
- mini_arcade_core.scenes.systems.builtins.maze.available_directions(tile_map: TileMap[TCell], coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, *, can_enter: Callable[[TCell | None], bool]) tuple[CardinalDirection, Ellipsis][source]¶
Return the cardinal exits available from one cell.
- mini_arcade_core.scenes.systems.builtins.maze.choose_direction_toward(tile_map: TileMap[TCell], coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, target: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, *, can_enter: Callable[[TCell | None], bool], current_direction: CardinalDirection | None = None, allow_reverse: bool = False) CardinalDirection | None[source]¶
Choose the exit that minimizes Manhattan distance to a target cell.
- mini_arcade_core.scenes.systems.builtins.maze.choose_direction_away(tile_map: TileMap[TCell], coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, target: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, *, can_enter: Callable[[TCell | None], bool], current_direction: CardinalDirection | None = None, allow_reverse: bool = False) CardinalDirection | None[source]¶
Choose the exit that maximizes Manhattan distance from a target cell.
- mini_arcade_core.scenes.systems.builtins.maze.choose_random_direction(tile_map: TileMap[TCell], coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, *, can_enter: Callable[[TCell | None], bool], rng: random.Random | None = None, current_direction: CardinalDirection | None = None, allow_reverse: bool = False) CardinalDirection | None[source]¶
Choose one valid exit randomly.
- mini_arcade_core.scenes.systems.builtins.maze.is_junction(tile_map: TileMap[TCell], coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, *, can_enter: Callable[[TCell | None], bool]) bool[source]¶
Return whether a cell exposes more than two valid exits.
Mutable cell-based movement state for one maze agent.
Bases:
Generic[TCtx,TCell]Declarative lane/junction navigation rule.
Bases:
Generic[TCtx,TCell]Advance one or more maze agents through a tile map with turn buffering.
Advance bound navigators through the tile map with turn buffering.
- class mini_arcade_core.scenes.systems.builtins.maze.TunnelWrapBinding[source]¶
Bases:
Generic[TCtx]Declarative horizontal/vertical wrap rule for maze agents.
- states_getter: Callable[[TCtx], Iterable[GridNavigatorState]]¶
- bounds_getter: Callable[[TCtx], mini_arcade_core.scenes.systems.builtins.grid.GridBounds]¶
- wrap_horizontal: bool = True¶
- wrap_vertical: bool = False¶
- class mini_arcade_core.scenes.systems.builtins.maze.TunnelWrapSystem[source]¶
Bases:
Generic[TCtx]Wrap maze agents across configured grid edges.
- name: str = 'common_tunnel_wrap'¶
- phase: int¶
- order: int = 31¶
- bindings: tuple[TunnelWrapBinding[TCtx], Ellipsis] = ()¶
- class mini_arcade_core.scenes.systems.builtins.maze.CollectibleKind[source]¶
Bases:
str,enum.EnumCommon collectible kinds for maze games.
- PELLET = 'pellet'¶
- POWER = 'power'¶
- BONUS = 'bonus'¶
- class mini_arcade_core.scenes.systems.builtins.maze.CollectibleState[source]¶
Mutable collectible metadata stored inside a field.
- kind: CollectibleKind¶
- payload: Any = None¶
- class mini_arcade_core.scenes.systems.builtins.maze.CollectibleField[source]¶
Dense collectible state keyed by grid cell.
- item_at(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord) CollectibleState | None[source]¶
Return the collectible stored at one cell, if any.
- occupied_cells() tuple[mini_arcade_core.scenes.systems.builtins.grid.GridCoord, Ellipsis][source]¶
Return the cells that currently contain collectibles.
- remove(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord) CollectibleState | None[source]¶
Remove and return the collectible stored at one cell.
- class mini_arcade_core.scenes.systems.builtins.maze.CollectibleCollisionBinding[source]¶
Bases:
Generic[TCtx]Declarative collectible pickup rule.
- collector_cell_getter: Callable[[TCtx], mini_arcade_core.scenes.systems.builtins.grid.GridCoord]¶
- field_getter: Callable[[TCtx], CollectibleField | None]¶
- on_collect: Callable[[TCtx, mini_arcade_core.scenes.systems.builtins.grid.GridCoord, CollectibleState], None] | None = None¶
- class mini_arcade_core.scenes.systems.builtins.maze.CollectibleCollisionSystem[source]¶
Bases:
Generic[TCtx]Consume collectibles when a collector enters the same cell.
- name: str = 'common_collectible_collision'¶
- phase: int¶
- order: int = 35¶
- bindings: tuple[CollectibleCollisionBinding[TCtx], Ellipsis] = ()¶
- class mini_arcade_core.scenes.systems.builtins.maze.TimedMode[source]¶
One timed gameplay mode segment.
- name: str¶
- duration_seconds: float | None¶
- payload: Any = None¶
- class mini_arcade_core.scenes.systems.builtins.maze.ModeTimerState[source]¶
Mutable state for timed mode progression.
- mode_index: int = 0¶
- elapsed_in_mode: float = 0.0¶
- current_mode: str = ''¶
- class mini_arcade_core.scenes.systems.builtins.maze.ModeTimerBinding[source]¶
Bases:
Generic[TCtx]Declarative timed mode schedule.
- state_getter: Callable[[TCtx], ModeTimerState]¶
- loop: bool = False¶