Update from vcha/stable#435
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Ocean Drive environment configuration and simulation code to add a new robustness knob (partner_blindness_trigger_prob) and refactors several C helper routines (grid entities, z-updates, stop-line checks, reward coefficient generation) for clearer structure and reduced duplication.
Changes:
- Add
partner_blindness_trigger_probend-to-end (INI parsing → Python env kwargs → C binding → C simulation), and apply it when masking partner observations. - Refactor Drive C implementation (grid-map entity representation, helper extraction for corner computation / z updates / episode summaries, small cleanups).
- Update example/demo C entrypoints to pass the new configuration field.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pufferlib/ocean/env_config.h | Adds INI parsing support for partner_blindness_trigger_prob. |
| pufferlib/ocean/drive/drive.py | Adds new Python kwarg, stores it, and passes it to C init kwargs. |
| pufferlib/ocean/drive/drive.h | Adds new Drive field; refactors helpers; applies new trigger probability in observation masking. |
| pufferlib/ocean/drive/drive.c | Wires new config field into demo/perf initialization. |
| pufferlib/ocean/drive/datatypes.h | Adds <stdlib.h> include (supports rand()/RAND_MAX usage). |
| pufferlib/ocean/drive/binding.c | Unpacks partner_blindness_trigger_prob from kwargs into the C env struct. |
| pufferlib/config/ocean/drive.ini | Documents and adds the new INI key. |
Comments suppressed due to low confidence (1)
pufferlib/ocean/drive/drive.h:2245
- collision_check iterates i < env->num_agents but indexes env->active_agent_indices / env->static_agent_indices. In set_active_agents(REPLAY), env->num_agents can exceed active_agent_count+static_agent_count (e.g., INIT_ONLY_CONTROLLABLE_AGENTS when agents are created but not stored in either index array), so this loop can read past static_agent_indices and then index env->agents[-/garbage], causing memory corruption. Consider iterating over (env->active_agent_count + env->static_agent_count) or ensuring env->num_agents is always kept equal to that sum.
for (int i = 0; i < env->num_agents; i++) {
int index = -1;
if (i < env->active_agent_count) {
index = env->active_agent_indices[i];
} else {
index = env->static_agent_indices[i - env->active_agent_count];
}
if (index == agent_idx) {
continue;
}
Agent *other_agent = &env->agents[index];
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1869,9 +1569,6 @@ | |||
| // Interpolate waypoints along route lanes | |||
| for (int route_idx = 0; route_idx < agent->route_length && wp_count < MAX_NUM_WP_PATH; route_idx++) { | |||
| int lane_idx = agent->route[route_idx]; | |||
Comment on lines
2392
to
2400
| for (int j = 0; j < env->num_agents; j++) { | ||
| int other_idx; | ||
| if (j < env->active_agent_count) { | ||
| other_idx = env->active_agent_indices[j]; | ||
| } else { | ||
| other_idx = env->static_agent_indices[j - env->active_agent_count]; | ||
| } | ||
| if (other_idx == -1) { | ||
| continue; | ||
| } | ||
| compute_pairwise_ttc(ego, ego_idx, &env->agents[other_idx], other_idx); | ||
| } |
Comment on lines
4216
to
4224
| AgentDistance candidates[env->num_agents]; | ||
| int candidate_count = 0; | ||
| for (int j = 0; j < env->num_agents; j++) { | ||
| int index = -1; | ||
| if (j < env->active_agent_count) { | ||
| index = env->active_agent_indices[j]; | ||
| } else if (j < env->num_agents) { | ||
| index = env->static_agent_indices[j - env->active_agent_count]; | ||
| } |
| lane_segment_dropout=0.0, | ||
| boundary_segment_dropout=0.0, | ||
| partner_blindness_prob=0.0, | ||
| partner_blindness_trigger_prob=0.1, |
eugenevinitsky
approved these changes
May 21, 2026
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.
No description provided.