Repository navigation
feat(hexmap): bit-parallel BFS search, distance, reachable and range (L1) - #133
Merged
Merged
Conversation
…(L1) Bfs::search runs one hex dilation per layer on two u128 limbs with a local bitwise triple, stores the layers and backtracks through them with the neighbour mask of the current tile. The first layer is the start neighbourhood and the loop stops on the layer that touches the target neighbourhood; open edge tiles are endpoints only. Layers closer than the hex distance skip the target test, boards of at most 128 bits run on a single limb, loops are unrolled four times. Adds Bfs::distance (forward pass only), Bfs::reachable and Bfs::tiles_within_range, tests against a scalar queue BFS (fixtures, random caves and mazes, edge entrances, corners, board extremes) and benchmarks with the measured losing variants in GAS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lot L1 of
origami_hexmap: the default pathfinder.Bfs::search(grid, width, height, from, to) -> Span<u8>: shortest path (unit cost, 6 neighbours), from the target (included) to the start (excluded), empty when unreachable orfrom == to. One hex dilation per layer on twou128limbs with a localbitwisetriple, layers stored, then backtracking with the neighbour mask of the current tile. Deterministic.Diggerentrances) can be endpoints; paths never cross another edge tile.Bfs::distance(..) -> Option<u8>: the forward pass only, ~70% ofsearch.Bfs::reachableandBfs::tiles_within_range(movement range with obstacles): open edge tiles are included when a path ends on them.Asserter: invalid dimension,Asserter: position not inside,Bfs: position not walkable.Gas (17x14, sierra gas, minus the 15_040 fixture baseline)
reachable276_581,keep_component283_755)origami_mapfor reference: its BFS medium test (4x4, path of 6) costs 1_608_464; the hex 7x7 EMPTY far search (path of 6) costs 131_733.reachable: −4 % to −8 % againstCaver::keep_componenton 17x14, about −40 % on 7x7.Every variant listed in the brief is implemented test-only in
bench_bfs.cairoand measured inGAS.md: layer storage, backtracking step, target test, bidirectional search, the single-limb path, the corelib operators and the scalar baseline.GAS.mdalso covers the iteration history (v1 to v12) and the Sierra code size of the close variants.Test plan
snforge test -p origami_hexmap: 538 passed, 0 failed, 3 ignored.Diggercorridors and mazes.reachableequalsCaver::keep_componenton caves;tiles_within_rangechecked for every radius.Test origami_hexmap(green, 8m23s).🤖 Generated with Claude Code