Skip to content

Fix: align C episode length with Python resample timing#379

Open
eugenevinitsky wants to merge 1 commit into3.0from
ev/fix-episode-length-alignment
Open

Fix: align C episode length with Python resample timing#379
eugenevinitsky wants to merge 1 commit into3.0from
ev/fix-episode-length-alignment

Conversation

@eugenevinitsky
Copy link
Copy Markdown

@eugenevinitsky eugenevinitsky commented Mar 29, 2026

Summary

C checked (env->timestep + 1) >= env->episode_length, causing episodes to end after episode_length - 1 steps. Python checked tick % resample_frequency == 0 after resample_frequency steps. This off-by-one meant C reset one step before Python resampled.

Changed C to env->timestep >= env->episode_length so both fire on the same step. Episodes now run for exactly episode_length steps.

Changed C check from (env->timestep + 1) >= env->episode_length to
env->timestep >= env->episode_length. Now both C and Python fire on
the same step:
- C: timestep incremented at start of c_step, reaches episode_length
  after exactly episode_length calls
- Python: tick incremented after vec_step, tick % resample_frequency == 0
  after exactly resample_frequency calls

No more off-by-one between episode end and map resample.
Episodes are now exactly episode_length steps (was episode_length - 1).
Copilot AI review requested due to automatic review settings March 29, 2026 19:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the Drive C environment’s episode time-limit semantics with Python’s resample timing by fixing a one-step early termination in the C step loop.

Changes:

  • Adjusts the C time-limit condition from (timestep + 1) >= episode_length to timestep >= episode_length to eliminate an off-by-one.
  • Ensures episodes run for exactly episode_length steps (with init_steps=0), matching Python’s tick % resample_frequency == 0 behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants