amaze.simu.maze

Data structures describing a maze and its parameters

Classes

Maze(data[, key])

Main data structure storing everything needed during simulation

class amaze.simu.maze.Maze(data: BuildData, key=None)[source]

Main data structure storing everything needed during simulation

class BuildData(
width: int = 10,
height: int = 10,
seed: int | None = None,
start: ~amaze.simu.types.StartLocation = StartLocation.SOUTH_WEST,
rotated: bool = True,
unicursive: bool = False,
clue: ~typing.List[~amaze.misc.resources.Sign] = <factory>,
lure: ~typing.List[~amaze.misc.resources.Sign] = <factory>,
p_lure: float | None = None,
trap: ~typing.List[~amaze.misc.resources.Sign] = <factory>,
p_trap: float | None = None,
)[source]

Structure describing all of a mazes parameters.

Used during building and thrown afterward. Also used for string conversion.

width: int = 10

The width of the maze

height: int = 10

The height

to_string(simplify: bool = False) str[source]

Generate a string representation of this object

Parameters:

simplify – Whether to simplify the resulting string

See:

from_string

classmethod from_string(
s,
overrides: BuildData | None = None,
) BuildData[source]

Parses a string to create a BuildData object.

The complete syntax is as follows, where every element is optional and can be in any order:

  • M[int]: maze will use that seed

  • [int]x[int]: maze will have those dimensions

  • [SE|SW|NE|NW]: the agent will start in that corner

  • U: maze will be unicursive (without intersections)

  • R: maze is not invariant to rotation

  • C[sign]: add one helpful sign type

  • L[sign]: add one mildly deceptive sign type

  • T[sign]: add one deceptive sign type

  • l: sets the probability for lures

  • t: sets the probability for traps

  • [sign]: specification for the sign shape/value

A sign specification contains two parameters:

  • C[shape]-[value]: sign will use the requested shape (either from

    the builtins() or an image file in resources_path())

  • C[value]: sign will have a default shape with the given value

Examples

  • M16_5x10_U

    Creates a maze 5 cells wide and 10 cells high from a random number generator seeded with 16. The maze will have no intersections.

  • 25x25_C1

    Creates a maze (from a random seed) of size 25 by 25 with white arrows at every intersection.

  • C1_C.5_l.25_L.25_L.2_L.3_t.5_T.75

    Creates a maze with two types of clues with white and gray arrows at half of the intersections. The remainder use a trap sign (still an arrow) in light gray. A quarter of the cell along the path to the target, that are not an intersection will contain lures of varying degree of dark gray (exactly one third each).

all_rotations()[source]

Returns a list describing the same maze with all four rotations

class Direction(value)[source]

One of the cardinal directions

class PlacedSign(visual_index, solution_index, direction, truth)

A physically instantiated sign with a position, …

direction

Alias for field number 2

solution_index

Alias for field number 1

truth

Alias for field number 3

visual_index

Alias for field number 0

stats()[source]

Prints various statistics about the maze :return: a dictionary of relevant attributes

maze_class()[source]

Determines the maze’s class based on its attributes

Returns:

the MazeClass

to_string()[source]

Provides the string representation of this maze

classmethod from_string(
s,
overrides: BuildData | None = None,
warnings=True,
) Maze[source]

Generate a maze from its string description.

Optionally, specific parameters can be overridden by values set in the overrides argument. The full syntax is described in BuildData.from_string().

all_rotations() List[Maze][source]

Returns all rotated versions of this maze