Skip to content

fix the burn through of goals at the beginning of the episode + test#503

Merged
riccardosavorgnan merged 2 commits into
3.0from
ricky/fix_replay_goal_burn_through
Jul 7, 2026
Merged

fix the burn through of goals at the beginning of the episode + test#503
riccardosavorgnan merged 2 commits into
3.0from
ricky/fix_replay_goal_burn_through

Conversation

@riccardosavorgnan

@riccardosavorgnan riccardosavorgnan commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes the burn through of waypoints at episode starts. The previous code burned through the goal at environment reset time, but advanced the alias of the actual goal only later in the step. This meant that if you spawn on a waypoint in replay mode, then consecutive waypoints would have been consumed because of the non updated "agent->goal_position_x" (which is only updated later in the c_step).

The test has been written with Claude and based on a map where we know the first waypoint is on the spawn point.

@@ -0,0 +1,223 @@
"""Tests that replay-mode waypoint progression burns exactly ONE waypoint per

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This comment should probably be compressed? For example, it contains the "how we got here" story

Comment on lines +15 to +26
get_state() exposes, per agent: the goal alias (goal_position_x/y), the
per-step reached-goal flag (metrics_array[REACHED_GOAL_METRIC_IDX], recomputed
every step), and the full logged trajectory. The expected waypoint list is
reconstructed with the same sampling formula c_reset uses in replay mode, so
each observed alias maps to a definite waypoint index k, and "one waypoint per
step" is asserted as: every fire moves k by exactly +1 (or saturates on the
final waypoint), and k never moves without a fire.

Note: env construction and env.reset() each run compute_metrics once at reset
time, and on this fixture each of those calls legitimately consumes one
waypoint. The tests account for that via the waypoint index of the post-reset
alias instead of assuming the episode starts at waypoint 0.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why does the reader of this test file need to know this?

@riccardosavorgnan riccardosavorgnan force-pushed the ricky/fix_replay_goal_burn_through branch from fae026e to a1302b6 Compare July 7, 2026 02:05

@Yvonne511 Yvonne511 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is perfectly good:
compute_metrics and current_goal_idx++ inside it could happen without step (in cases where reset is already on goal). Hence, current_goal_idx++ and update agent->current_goal should happen together. Update agent->current_goal should not be constrained inside step.

@riccardosavorgnan riccardosavorgnan merged commit 33c0cdb into 3.0 Jul 7, 2026
13 checks passed
@riccardosavorgnan riccardosavorgnan deleted the ricky/fix_replay_goal_burn_through branch July 7, 2026 03:33
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.

3 participants