Unit 12 of 13 · about 3 hours · implement

Trajectory schemas with environment, policy, seed and version identity

RL results change with seeds and versions. Without identity on each record, no comparison is reproducible and no defect is attributable.

You'll be able to

  • Define a trajectory record that binds environment, policy, seed and versions to every transition.
  • Separate training and evaluation streams with distinct seeds and no shared exploration.
  • Validate records: reject missing identity fields before any update runs.

Covers

Trajectory schemas with environment, policy, seed and version identity
1

Read

In this order, only the parts listed

0 of 2 done

  1. Seeding, spec identity and step fieldsGymnasium Core API

    reset with seed called once after construction, the spec version identity, and the terminated, truncated and info step fields (Gymnasium 1.4.0; page read 2026-10-14)

  2. Shared schema in the control laboratoryReinforcement Learning Control Laboratory - Tabular Control

    Core requirements and Architecture constraints: one shared transition and trajectory schema with policy and environment version

2

Focus on

  • Each record carries environment id and version, policy id and version, seed, step index, , flags and versions. Analysis joins on identity, never on row order.
  • Evaluation uses distinct seed streams and no training exploration unless the comparison states it. Shared streams leak training noise into evaluation.
  • Wrappers must not change rewards or termination silently. If a wrapper alters either, its version changes and old records stop mixing with new ones.
Common mistakes · 3
  • Reseeding every episode identically. The same seed replays the same trajectory; streams need distinct seeds drawn from one master seed.
  • Storing only the environment id. Library versions change dynamics and autoreset behavior, so the version is part of identity.
  • Letting evaluation share the training RNG. Exploration settings then leak across the boundary the schema was built to enforce.
3

Try it yourself

Closed-book, before checking anything

From a blank file, emit one JSON record for a CliffWalking-v1 step with environment version, policy id, seed, terminated, truncated and reward, then show a loader accepting it and rejecting the same record with the seed deleted.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Two runs differ only in library version. Comparable?Answer

    Not directly. Version is part of identity; re-run or analyze separately.

  2. 2.What breaks if the seed is missing from records?Answer

    Attribution. A strange trajectory cannot be replayed or tied to its stream.

  3. 3.A wrapper clips rewards but keeps the old version. Acceptable?Answer

    No. Silent reward changes invalidate every comparison; version the wrapper and segregate records.

You're done when

Your loader round-trips a versioned record, rejects identity gaps, and your evaluation streams run on seeds the trainer never used.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 5 more in the section
  • Gymnasium Core APIFarama Foundation · reference

    Use the reset, step, seeding and wrapper documentation as the behavior authority for the installed environment version: reset(seed=...) seeds once, step returns terminated and truncated, and vector environments autoreset on the next step by default. Test observation, reward, terminated, truncated and info fields at the boundary.

  • Reinforcement Learning Control Laboratory - Tabular ControlRoadmap-Final · required

    Complete the MC, SARSA and Q-learning requirements with exact trajectory updates, stochastic and exploration-sensitive environments, visitation logs, matched interaction budgets and seeded alignment and bootstrap defects.

Also in this section

  • Reinforcement Learning: An Introduction (2nd ed.) - Chapters 2, 5, 6 and 7Richard Sutton and Andrew Barto · primary

    The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Sections 2.4 and 2.5 (incremental and constant step-size estimates), Chapter 5 without the starred sections (Monte Carlo prediction and control, ordinary and weighted importance sampling), Chapter 6 Sections 6.1 to 6.7 (TD(0), Sarsa, Q-learning, Expected Sarsa, maximization bias) and Chapter 7 Sections 7.1 to 7.3 (n-step methods). Reproduce Example 5.4 (off-policy blackjack), Example 6.2 (random walk) and Example 6.6 (cliff walking), and implement each update from fixed hand-calculated trajectories before training an agent.

  • Stanford CS234 Winter 2026 - Policy Evaluation and Q-LearningStanford University · required

    Study Lecture 3 (tabular policy evaluation) and Lecture 4 (Q-learning) slides and the relevant independent Assignment 1 and 2 written questions. Use the course treatment to state model-access, convergence, coverage and function-approximation assumptions for each update.

  • Hands-on Modern RL - Dynamic Programming, Monte Carlo and TDWalking Labs · support

    Use the DP, MC and TD page and the bandit script as a code companion. Rebuild the algorithms in the shared track schema, and keep the bandit comparison as a seed-sensitivity case: which method wins changes with the seed. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its code/chapterNN folders do not follow the site chapter numbers.

  • Deep-ML - Tabular Prediction and Control ProblemsDeep-ML · support

    Use named problems as closed-book checks after your own implementation passes: 272 (first-visit Monte Carlo), 257 (TD error), 273 (n-step TD), 175 (SARSA), 476 (Expected SARSA), 133 (Q-learning) and 518 (cliff walking, SARSA versus Q-learning). Read each problem's tests before trusting its statement.

  • Reinforcement Learning: An Introduction (2nd ed.) - Starred Sections 5.8 and 5.9 and Chapter 10 Sections 10.3 to 10.5Richard Sutton and Andrew Barto · support

    Study starred Section 5.9 on per-decision importance sampling only for the per-decision estimator, and Chapter 10 Sections 10.3 to 10.5 on average reward and differential values only for the continuing-task unit. Cite printed pages; the authors post the full text free at incompleteideas.net.