The environment is the problem statement
In supervised learning you start with a dataset. In reinforcement learning you start with an environment: a small world that receives your agent's action, changes its state, and hands back a reward. Together the agent and environment form a loop that runs over and over, and that loop is your entire problem. Choosing or building the right environment is not setup — it is the research question.
A diagram showing an agent sending an action to the environment, which returns an observation and reward in a loop.
A field-wide vocabulary grew up around shared worlds and shared scorecards: environments and benchmarks. An environment is the simulator or task; a benchmark is an agreed set of environments plus a way to score and compare agents. Shared benchmarks are why we can say one algorithm 'beats' another at all.
The Gym / Gymnasium contract
Almost every modern RL codebase speaks one tiny interface, popularized by OpenAI Gym and now maintained as Gymnasium. It is just two methods: `reset()` starts a fresh episode and returns the first observation; `step(action)` applies an action and returns the next observation, the reward, and flags saying whether the episode ended.
obs, info = env.reset(seed=0)
done = False
while not done:
action = policy(obs) # agent chooses
obs, reward, terminated, truncated, info = env.step(action)
done = terminated or truncated # natural end vs time limitBecause the contract is so thin, an agent written against it can be dropped onto a cart-pole, an Atari game, or a robot simulator without changing a line. That portability is the quiet superpower of the ecosystem: write the policy once, swap the world underneath.
The classic proving grounds
Two benchmark families defined deep RL's first decade. The Arcade Learning Environment (ALE) wraps dozens of Atari 2600 games behind the same screen-pixels-in, joystick-out interface; the Atari benchmark built on it became the standard test of learning from raw pixels with a single network. On the continuous-control side, MuJoCo supplies fast, differentiable physics for locomotion tasks — making a simulated cheetah run or a humanoid stay upright.
A convolutional network pipeline turning an image into pooled features and a classification or action output.
What makes a benchmark honest
A benchmark is only useful if a high score means real competence rather than lucky tuning. RL results are notoriously fragile: the same algorithm can swing wildly across random seeds, and a leaderboard number polished by hundreds of hyperparameter trials may not survive on a new task. Honest reporting means many seeds, confidence intervals, fixed evaluation budgets, and held-out variations.
There is also a subtler trap: tuning your reward until the benchmark score looks good can quietly teach the agent to exploit the benchmark instead of solving the task. We will return to this craft in depth — see reward engineering practice — because in applied RL it is where most projects live or die.
From benchmark to your own world
Eventually you leave the standard suites and wrap your own problem as an environment — a warehouse, a trading book, a recommendation feed. The skill is to map your messy domain onto the same clean `reset`/`step` contract.
The discounted return: the single cumulative number a benchmark scores, summing each step's reward with a discount factor γ.
- Define the observation: what does the agent actually see each step, and is it enough to act on (or is the true state hidden)?
- Define the action space: discrete buttons, continuous knobs, or a structured choice — keep it as small as the task allows.
- Define the reward: the single number that, if maximized, yields the behavior you actually want.
- Define episode boundaries: when does a run reset, and what counts as success or failure?
- Validate with a trivial agent: a random policy and a hand-coded baseline should behave sanely before you train anything.