amaze.simu.simulation

Classes

Simulation([maze, robot, save_trajectory, ...])

Serves as a bare-bones simulator for the maze-navigation environment.

class amaze.simu.simulation.Simulation(
maze: None | Maze = None,
robot: BuildData | None = None,
save_trajectory=False,
deadline_factor=4,
)[source]

Serves as a bare-bones simulator for the maze-navigation environment.

Handles all three configurations: full discrete, full continuous and hybrid

ImageVisual

alias of ndarray

NoVisual

alias of float

success()[source]

Return whether the agent has reached the target

failure()[source]

Return whether the agent has exceeded the deadline

done()[source]

Return whether the simulation has run its course

@see success() and failure() to check the outcome

normalized_reward()[source]

Return the agent’s cumulative reward in \([-1, 1]\)

infos()[source]

Returns various data about the current state of the simulation

run(controller)[source]

Let the agent navigate in the maze until completion

step(action: Vec) float | None[source]

Apply the requested action to the agent and return the corresponding reward

classmethod compute_metrics(
maze: Maze,
inputs: InputType,
vision: int,
) dict[MazeMetrics | str][source]

Computes metrics about a maze.

Parameters:
  • maze – The maze to process

  • inputs – The type of inputs (currently unused)

  • vision – The agent’s retina size (currently unused)

Returns:

a dictionary of the different metrics

classmethod inputs_evaluation(
results_path: Path | str,
controller: BaseController,
signs: dict[SignType, List[Sign]],
empty_intersections: bool = False,
draw_inputs: bool = False,
draw_individual_files: bool = False,
draw_summary_file: bool = True,
summary_file_ratio: float = 1.7777777777777777,
)[source]

Evaluates the provided controller on all possible inputs.

Uses the provided lists of clues/lures/traps and tests the controller’s capacity to take the appropriate action in all cases. Unlike conventional, maze-navigation evaluation for generalization performance evaluation, this method does not suffer from cumulative failure (e.g. missing one intersection may prevent reaching the goal).

Warning

Only available for fully discrete and hybrid spaces

Parameters:
  • results_path – Folder under which to store the resulting files.

  • controller – Controller to evaluate.

  • signs – Dictionary of clues/lures/traps.

  • empty_intersections – Also evaluate agent on intersections without signs (nasty, disabled by default)

  • draw_inputs – Whether to draw inputs (without the actions)

  • draw_individual_files – Whether to generate a separate file for every input/action

  • draw_summary_file – Whether to generate a summary file for all input/action pairs

  • summary_file_ratio – Width/Height ratio of the summary file

classmethod inputs_evaluation_from(
simulation: Simulation,
results_path: Path | str,
controller: BaseController,
**kwargs,
)[source]

Evaluates the provided controller on all possible inputs.

Uses the simulation’s maze to generate the list of clues/lures/traps and delegates to inputs_evaluation().

Warning

Only available for fully discrete and hybrid spaces

Parameters:
  • simulation – The simulation to grab maze data from.

  • results_path – Folder under which to store the resulting files.

  • controller – Controller to evaluate.

  • kwargs – Additional keyword arguments.