Skip to content

Avoid allocation in integer walkability queries - #4

Merged
dgant merged 2 commits into
developfrom
allocationless-iswalkable
Nov 4, 2026
Merged

dgant merged 2 commits into
developfrom
allocationless-iswalkable

Conversation

@dgant

@dgant dgant commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Game.isWalkable(int, int) now checks walk-grid bounds and reads the walkability array directly, avoiding construction of a WalkPosition. The WalkPosition overload delegates to the integer overload so both use the same bounds checks.

In-map results are preserved. As a correctness consequence of comparing coordinates directly with the map bounds, both overloads consistently return false for out-of-range coordinates, including very large positive values.

Validation:

  • Full Maven package on Windows Java 8u171 x86: all 44 tests pass on 2068443, with zero failures, errors, or skips.
  • Both overloads are checked against the fixture's map data across every walk tile, including walkable and blocked terrain.
  • Both overloads reject negative coordinates, the map boundary, and very large positive coordinates.
  • The preceding implementation at cd27cd8 completed a full PurpleWave game versus Stardust on Fighting Spirit: 11,875 frames, normal defeat, no crash or timeout. That game predates this overload-delegation cleanup.

@dgant
dgant merged commit 5025875 into develop Nov 4, 2026
11 checks passed
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