Log inStart free
LESSON 16.21 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

The Gymnasium contract

One warehouse env runs the whole Gymnasium contract, from reset to close.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 16.21 · RL BAYACTIONS 7 · OBSERVATION FIELDS 6
01
Stage 1 of 6 · The contract
The env class declares its action space and its observation space. Its metadata lists the render modes.
Explain it simply

Before any step, the class says what goes in and what comes out. The action space is seven numbers, zero to six, one for each chip. The observation space is a dictionary of six fields, each with its own range. The shelf stock is not in it, so the agent never sees it.

Left: the warehouse floor and 7 action chips. Right: the metadata and 6 observation fields with their spaces.

robot, observationspaces, time budget, truncatedactions, reward, terminatedrejected actionparked cart
the contractthe env's state1234P5A6789C101112131415161718B19K20212223Raction_space = Discrete(7)0 up1 right2 down3 left4 pick5 pack6 waitenv = WarehouseEnv(render_mode="rgb_array")metadata{"render_modes": ["ansi", "rgb_array"], "render_fps": 4}observation_space = Dict({"cell"Discrete(24)"carried"MultiDiscrete([3 3 3])"battery"Discrete(25)"packed"MultiDiscrete([3 3 3])"order"MultiBinary(3)"t"Discrete(31)the contractthe env's state1234P5A6789C101112131415161718B19K20212223Raction_space = Discrete(7)0 up1 right2 down3 left4 pick5 pack6 waitenv = WarehouseEnv(render_mode="rgb_array")metadata{"render_modes": ["ansi", "rgb_array"], "render_fps": 4}observation_space = Dict({"cell"Discrete(24)"carried"MultiDiscrete([3 3 3])"battery"Discrete(25)"packed"MultiDiscrete([3 3 3])"order"MultiBinary(3)"t"Discrete(31)
Toy: the 16.C2 warehouse as a Gymnasium env; one episode from reset with seed 42
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
a∈Discrete(7),o∈Dict(6 fields)\sy{a}{out}{a} \in \text{Discrete}(7), \quad \sy{o}{data}{o} \in \text{Dict}(6\ \text{fields})
cell∈{0,…,23}, battery∈{0,…,24}, t∈{0,…,30}\text{cell} \in \{0, \dots, 23\},\ \text{battery} \in \{0, \dots, 24\},\ t \in \{0, \dots, 30\}

Each action is one of 7 numbers, and each observation is a dict.

Common mix-ups

MYTHTerminated and truncated both mean the episode is over.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With the reset option battery 12, does the planner's episode end terminated or truncated?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.