Principle:Farama Foundation Gymnasium Observation Action Space Design
| Knowledge Sources | |
|---|---|
| Domains | Reinforcement_Learning, Space_Definition |
| Last Updated | 2026-02-15 03:00 GMT |
Overview
The practice of formally defining the mathematical structure and constraints of observations and actions in an RL environment using typed space objects.
Description
Observation and Action Space Design is the process of choosing appropriate mathematical representations for what an agent perceives (observations) and what it can do (actions). Gymnasium provides a hierarchy of Space types:
- Box: Continuous n-dimensional arrays with per-element bounds. Used for physical quantities (positions, velocities, pixel images).
- Discrete: Finite set of integers. Used for categorical choices (move directions, card actions).
- Dict: Named dictionary of sub-spaces. Used for structured observations with heterogeneous components.
- MultiBinary / MultiDiscrete: Binary vectors and multi-dimensional discrete spaces.
- Tuple / Sequence / Graph: Composite spaces for complex structures.
Space design determines:
- What inputs the agent network must accept
- What outputs the agent must produce
- How random exploration (sampling) works
- How environment validation (env_checker) verifies correctness
Usage
Use space design when implementing custom environments. The observation_space and action_space must be set in __init__ as Space objects. Choose Box for continuous values, Discrete for finite choices, and Dict for structured multi-component observations.
Theoretical Basis
In the MDP formulation:
- State/observation space defines all possible states
- Action space defines all possible actions
Gymnasium spaces provide:
- Sampling: for exploration
- Containment: for validation
- Flattening: for neural network input