Skip to content

MetaMaze-misc

MetaMaze

MetaMaze(maze_size: int = 9, rf_size: int = 3)

Bases: Environment[EnvState, EnvParams]

Repeatedly find a hidden goal in a grid maze from local observations.

Meta-learning maze as in Miconi et al. (2019). The maze is a square grid in which every second cell of every second row is a wall, surrounded by an outer wall. The goal is sampled uniformly from all walkable cells at every reset and stays fixed for the whole episode. The agent starts at center_position, the centre of the maze for the default rf_size (other values shift it; rf_size = 5 places it on a wall), and is moved to a uniformly sampled walkable cell each time it reaches the goal. Moving into a wall leaves the position unchanged.

  • Observation: Box of shape (rf_size**2 + 6,) with the flattened rf_size x rf_size wall map around the agent (1 for walls), the one-hot encoded last action, the last reward and the time step (normalized if params.normalize_time).
  • Actions: Discrete(4). 0 moves up, 1 right, 2 down and 3 left.
  • Reward: params.reward for reaching the goal, plus params.punishment for moving into a wall.
  • Termination: the agent's position equals the goal at the end of a step. As the agent is moved on reaching the goal, this only happens if the newly sampled position is the goal cell itself.
  • Truncation: after params.max_steps_in_episode steps (200 by default).

Parameters:

  • maze_size (int, default: 9 ) –

    Number of rows and columns of the maze without the outer wall. Must be odd.

  • rf_size (int, default: 3 ) –

    Side length of the square receptive field observed around the agent. Must be odd and larger than 1.

References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the MetaMaze environment.

The default values are inspired by the SimpleMaze implementation.

Attributes:

  • reward (float) –

    Reward for reaching the goal.

  • punishment (float) –

    Value added to the reward when the agent moves into a wall.

  • normalize_time (bool) –

    Whether the time step in the observation is rescaled so that steps 0 and 100 map to -1 and 1, instead of given as a raw step count.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the MetaMaze environment.

Attributes:

  • last_action (int) –

    Action taken in the previous step (0 after a reset).

  • last_reward (Array) –

    Reward received in the previous step (0 after a reset).

  • pos (Array) –

    Agent position as (row, column) in the padded maze map.

  • goal (Array) –

    Goal position as (row, column) in the padded maze map.

  • time (float) –

    Number of steps taken in the current episode.