Skip to content

FourRooms-misc

FourRooms

FourRooms(use_visual_obs: bool = False, goal_fixed: list[int] | None = None, pos_fixed: list[int] | None = None)

Bases: Environment[EnvState, EnvParams]

Navigate through four connected rooms to a goal cell.

Four Rooms grid world as in Sutton et al. (1999), comparable to gym-fourrooms. The 13 x 13 map consists of four rooms that are connected by single-cell doorways. Moving into a wall leaves the position unchanged, and with probability params.fail_prob a different action than the chosen one is executed. Since gymnax automatically resets the environment when an episode ends, the reset variants are selected via the parameters: start and goal are either fixed (pos_fixed, goal_fixed) or, if params.resample_init_pos or params.resample_goal_pos is set, sampled uniformly from the open cells at every reset. A sampled start never coincides with the goal.

  • Observation: Box of shape (4,) with the row and column of the agent followed by the row and column of the goal. If use_visual_obs, a Box of shape (13, 13, 2) with a wall map (1 for walls) and a one-hot map of the agent position. The agent map is indexed as [column, row], transposed relative to the wall map.
  • Actions: Discrete(4). 0 moves up, 1 right, 2 down and 3 left.
  • Reward: 1 for reaching the goal, otherwise 0.
  • Termination: the agent reaches the goal.
  • Truncation: after params.max_steps_in_episode steps (500 by default).

Parameters:

  • use_visual_obs (bool, default: False ) –

    Whether to return the image observation instead of the agent and goal coordinates.

  • goal_fixed (list[int] | None, default: None ) –

    Goal position as [row, column] that is used unless params.resample_goal_pos is set. Defaults to [8, 9].

  • pos_fixed (list[int] | None, default: None ) –

    Start position as [row, column] that is used unless params.resample_init_pos is set. Defaults to [4, 1].

References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the FourRooms environment.

Attributes:

  • fail_prob (float) –

    Probability that one of the three other actions is executed instead of the chosen one. Implemented by replacing the action with a uniformly random one with probability fail_prob * 4 / 3.

  • resample_init_pos (bool) –

    Whether the start position is sampled at every reset instead of using the fixed start position.

  • resample_goal_pos (bool) –

    Whether the goal position is sampled at every reset instead of using the fixed goal position.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the FourRooms environment.

Attributes:

  • pos (Array) –

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

  • goal (Array) –

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

  • time (int) –

    Number of steps taken in the current episode.