Skip to content

Fix FlowField bounds and unreachable navigation vectors - #1488

Open
huxiaoyi-ovo wants to merge 6 commits into
AtsushiSakai:masterfrom
huxiaoyi-ovo:fix/flow-field-boundary-and-unreachable
Open

huxiaoyi-ovo wants to merge 6 commits into
AtsushiSakai:masterfrom
huxiaoyi-ovo:fix/flow-field-boundary-and-unreachable

Conversation

@huxiaoyi-ovo

@huxiaoyi-ovo huxiaoyi-ovo commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

FlowField assumes every cell has valid neighbors in the 3×3 neighborhood. On unpadded maps, both integration-field propagation and direction assignment can index cells outside the grid and raise KeyError.

It also attempts to choose a navigation direction for goal-disconnected regions even though all reachable-cost values there are infinite. These cells should not point toward an arbitrary invalid neighbor.

Fix

  • During integration propagation, visit only cells already registered in integration_field (the traversable cells within map bounds).
  • During vector assignment, consider only valid, finite-cost neighbors.
  • Assign (None, None) to cells disconnected from the goal, allowing path following to terminate rather than follow an undefined direction.
  • Prevent the animation loop from attempting to plot the (None, None) termination marker after reaching the goal or encountering an unreachable cell.
  • Preserve the existing cost model, search propagation, and public interface.

Regression tests

Added four focused cases:

  1. An unpadded 3×3 free grid with the goal at a corner. Every generated direction must lead to the goal without revisiting a cell.
  2. A 4×4 grid separated by a solid wall. An unreachable start has infinite integration cost and no navigation direction.
  3. A one-cell map whose start equals the goal.
  4. An animation-enabled two-cell path that confirms the terminal sentinel is not passed to Matplotlib.

Scope: two files; no new dependencies.

Validation: The four focused edge cases pass in an isolated local reproduction of the updated FlowField methods (4/4). Full cross-platform repository CI is still pending: the fork validation PR #11 has not produced Actions runs yet, and the upstream checks require maintainer action.

AI disclosure: ChatGPT assisted with code analysis, the fix, and regression tests.

@huxiaoyi-ovo
huxiaoyi-ovo marked this pull request as ready for review October 30, 2026 09:07
Exercise every cell on an unpadded free grid and keep test formatting consistent.

Co-authored-by: ChatGPT (OpenAI GPT-6) <noreply@openai.com>

This branch has not been deployed

No deployments
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.

1 participant