Fix: align C episode length with Python resample timing#379
Open
eugenevinitsky wants to merge 1 commit into3.0from
Open
Fix: align C episode length with Python resample timing#379eugenevinitsky wants to merge 1 commit into3.0from
eugenevinitsky wants to merge 1 commit into3.0from
Conversation
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).
There was a problem hiding this comment.
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_lengthtotimestep >= episode_lengthto eliminate an off-by-one. - Ensures episodes run for exactly
episode_lengthsteps (withinit_steps=0), matching Python’stick % resample_frequency == 0behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
C checked
(env->timestep + 1) >= env->episode_length, causing episodes to end afterepisode_length - 1steps. Python checkedtick % resample_frequency == 0afterresample_frequencysteps. This off-by-one meant C reset one step before Python resampled.Changed C to
env->timestep >= env->episode_lengthso both fire on the same step. Episodes now run for exactlyepisode_lengthsteps.