Skip to content

Respect obstacles when smoothing paths - #88

Open
civilwarinfrance wants to merge 2 commits into
brean:mainfrom
civilwarinfrance:fix/smooth-path-obstacles
Open

civilwarinfrance wants to merge 2 commits into
brean:mainfrom
civilwarinfrance:fix/smooth-path-obstacles

Conversation

@civilwarinfrance

Copy link
Copy Markdown
Contributor

Related #21, which identified the inverted obstacle check in an earlier, unmerged proposal.

With a blocked center cell, smoothing [[0, 0], [0, 2], [2, 2]] currently removes the bend and returns a diagonal through the obstacle. The loop excludes the destination, so that final shortcut is never checked. On empty grids, the inverted condition also retains unnecessary waypoints.

Keep the last visible waypoint when a shortcut is blocked, and check every candidate through the destination. Return empty/single-waypoint paths without indexing past the input. Correct the existing empty-grid test to expect just the endpoints, and add obstacle, reverse-direction and short-input regressions for both interpolation modes.

Validation:

  • Ten new cases fail on current main; two short-input controls pass. All 60 project tests pass after the fix (Python 3.14.6, including NumPy/pandas tests).
  • 400 smoothed routes across 100 generated mazes pass endpoint, waypoint-order and mode-specific obstacle checks, in both directions and both interpolation modes.
  • For ray-traced smoothing, an independent exact-rational segment/square intersection check also confirms that all 779 returned segments avoid obstacle interiors. Existing corner-tie behavior is unchanged.
  • Whitespace checks pass.

AI assistance: This patch, tests and description were prepared with Codex (GPT-6).

@brean brean added the question Further information is requested label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants