Add square-grid neighbor queries #6

Merged
fputs merged 1 commit from fputs/grid into master 2026-11-05 09:33:02 -08:00 AGit
Owner

Adds square-grid queries on lfmath.h: bounds, Manhattan, Chebyshev, and 4- and 8-neighbor lists. No allocation. A too-small destination is left unchanged. Neighbor order is east, north, west, south, then northeast, northwest, southwest, southeast. +x is east and +y is north. Coordinates that would overflow int are omitted. This does not go through bresenham.

Chebyshev is max(|dx|, |dy|). (0,0) to (3,4) is Chebyshev 4 and Manhattan 7. The brief's parenthetical said 3 and 7; 3 is not the Chebyshev distance, so the test expects 4.

Tested with -DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF. ctest --label-exclude slow: 25/25 passed.

Adds square-grid queries on `lfmath.h`: bounds, Manhattan, Chebyshev, and 4- and 8-neighbor lists. No allocation. A too-small destination is left unchanged. Neighbor order is east, north, west, south, then northeast, northwest, southwest, southeast. `+x` is east and `+y` is north. Coordinates that would overflow `int` are omitted. This does not go through `bresenham`. Chebyshev is `max(|dx|, |dy|)`. `(0,0)` to `(3,4)` is Chebyshev 4 and Manhattan 7. The brief's parenthetical said 3 and 7; 3 is not the Chebyshev distance, so the test expects 4. Tested with `-DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF`. `ctest --label-exclude slow`: 25/25 passed.
Add square-grid neighbor queries
All checks were successful
test / test (pull_request) Successful in 14s
test / sanitize (pull_request) Successful in 15s
cb964d126b
fputs merged commit db59f6c3f4 into master 2026-11-05 09:33:02 -08:00
fputs referenced this pull request from a commit 2026-11-05 09:33:03 -08:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
fputs/libflint!6
No description provided.