DeepSea-bsuite¶
DeepSea ¶
Bases: Environment[EnvState, EnvParams]
Reach the last column of a square grid by moving right in every row.
JAX port of the bsuite DeepSea environment. The agent starts in row 0 and
column 0 and moves down one row per step, so an episode lasts size steps. The
only positive reward requires the "right" action in every row, while each
"right" action has a small cost, which makes the task a test of exploration.
- Observation:
Boxof shape(size, size)that is 0 everywhere except for a 1 at the agent's cell. All zeros once the agent has left the last row. - Actions:
Discrete(2). In each cell one action moves the agent one column to the right and the other one column to the left, as given bystate.action_mapping. The agent stays within the grid. - Reward: 1 for choosing the "right" action in the last column, which can only
be reached in the last row. Every "right" action costs
params.unscaled_move_cost / size. Ifparams.deterministicisFalse, standard normal noise is added in the first and last column of the last row. - Termination: the agent leaves the last row, which takes
sizesteps. - Truncation: after
params.max_steps_in_episodesteps.default_paramssets this tosize, so the last step of an episode is then flagged as both terminated and truncated.
Parameters:
-
size(int, default:8) –Number of rows and columns of the grid.
-
action_mapping_key(Array | None, default:None) –PRNG key used to draw the fixed action mapping, which assigns the "right" action to 0 or 1 independently for every cell. Defaults to
jax.random.key(0).
References
Parameters and state¶
EnvParams ¶
Bases: EnvParams
Parameters of the DeepSea environment.
Attributes:
-
deterministic(bool) –If
True, the "right" action always moves the agent to the right. IfFalse, it only does so with probability1 - 1 / sizeand otherwise leaves the column unchanged, and standard normal noise is added to the reward in the first and last column of the last row. -
sample_action_map(bool) –If
True, sample a new action mapping at every reset instead of using a fixed one. -
unscaled_move_cost(float) –Cost of the "right" action. It is divided by
sizebefore it is subtracted from the reward. -
randomize_actions(bool) –If
True, use the action mapping drawn when the environment was constructed. IfFalse, action 1 moves right in every cell. Ignored ifsample_action_mapisTrue. -
max_steps_in_episode(int) –Number of steps after which the episode is truncated.
DeepSea.default_paramssets it tosize.
EnvState ¶
Bases: EnvState
State of the DeepSea environment.
Attributes:
-
row(int) –Row of the agent. Starts at 0 and increases by one every step.
-
column(int) –Column of the agent.
-
bad_episode(bool) –Whether the agent has taken the "left" action in a cell with
row == columnduring the current episode. -
total_bad_episodes(int) –Number of finished episodes in which
bad_episodewas set.stepcarries it over when the environment auto-resets. -
denoised_return(int) –Number of times the goal reward of 1 was collected, without move costs or reward noise.
stepcarries it over when the environment auto-resets. -
optimal_return(float) –Expected return of always choosing the "right" action: the probability of reaching the last column (1 if
params.deterministic, else(1 - 1 / size) ** (size - 1)) minusparams.unscaled_move_cost. -
action_mapping(Array) –Integer array of shape
(size, size)holding, for every cell, the action that moves the agent to the right. -
time(int) –Number of steps taken in the current episode.