amaze.simu.maze¶
Data structures describing a maze and its parameters
Classes
|
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,
Structure describing all of a mazes parameters.
Used during building and thrown afterward. Also used for string conversion.
- 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( ) 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 inresources_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).
- 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
- classmethod from_string( ) 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().