feat(hexmap): hex maze generator and digger (L5) - #129
Merged
Merged
Conversation
Mazer::generate: randomised backtracker over 6 directions with one mask test per candidate (2^c * K, K a per-direction field constant), only the 3 forward neighbours as candidates, per-direction code via Heading impls. Order 0: one-tile corridors and walls; order 1: two open tiles at distance 2 always share an open neighbour; order >= 2 panics. Digger::corridor / Digger::maze: open an edge entrance and dig with the same rule until the dug tiles touch the original grid (stop or merge). 17x14 order 0: 2.88M gas (32k per tile, origami_map 229k per tile). Variants and budgets in GAS.md and tests/bench_mazer.cairo. 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 L5 of
origami_hexmap:Mazer::generate,Digger::corridorandDigger::maze.maze & 2^c * K(K: field constant per direction and parity). Only the 3 forward neighbours of a tile are candidates (the other two touch its parent), and a carved middle candidate excludes both sides without a test. The direction logic is specialised at compile time (Headingimpls).Mazer: order > 1 not supported(same message asorigami_map). The order is asserted once.corridorstops andmazemerges the grid and keeps growing.Gas (17x14, sierra gas)
generate(17, 14, 0)(target < 3M)generate(17, 14, 1)corridor(3x2 room)maze(3x2 room)origami_map18x14 maze, order 0Every variant from the brief is implemented and measured in
tests/bench_mazer.cairo: explicit stack +51 %, per-neighbour bit tests +220 %, felt maze +1.9 %,DivRemcoordinates +12.4 %, lazy draws +7.4 %,shuffle6+199 %, rotation order -1.7 % per tile (not adopted: below 2 % and biased). Iteration history is inGAS.md.Tests
Layout::expand, tree property (edges = tiles - 1), the order-1 distance-2 rule, and every carve mask checked against its definition fromGeometry::distance.Deviation
The digger stops (or merges) when a dug tile touches the open area.
origami_mapstops when it steps onto it. On hexes, touching already means connected; stepping onto it made corridors run along the room before entering it.🤖 Generated with Claude Code