Add MAZE — generalized BFS / weighted shortest-path search#187
Merged
Conversation
Body recreated verbatim from issue #184 (BFSMaze_2 spec); parameter names preserved as-written so the first commit faithfully matches the source. Internal LET-variable renames for readability are deferred to a follow-up commit. Capabilities: coordinate-frame map range, optional Cost surface, optional Targets list, 4-way / 8-way / custom direction sets, optional walkability mask, and a user-supplied per-edge cost LAMBDA. With Targets omitted the function returns the full distance grid spanning the map; with Targets provided it returns a column of distances (NA for unreachable). Tests cover uniform-cost full-grid output, target-list lookup, walkability detour, custom cost surface, the step counter, and a diagonal-1.5x Mazelam. The full-grid case is laid out at G3:I5 so the 3x3 spill from A1 doesn't collide with seeded data. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
For lambdas whose output spills as a full-grid-shape array from A1, a seeded input range that overlaps the spill rectangle produces #SPILL! and surfaces in the harness as the same NullReferenceException at Marshal.ReleaseComObject seen for scalar/error returns — easy to misdiagnose. Captured the cause, the safe layout (data starting at col output_cols+2), and the note that scalar-output cases are unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pure rename — every user-facing parameter (mp, st, Cost, Targets, No_Diag, Allowmp, Show_Steps, Cus_Dir, Mazelam) is unchanged, and no logic, ordering, or formula was modified. Key renames inside the body: xRC → moveSet (active direction set) nv → noRowCol (mp is array constant, not real range) cn/rn → colArr/rowArr rcn → posGrid (row*M + col encoded) ir/ic → rowOffset/colOffset rcst → startPos costG → costGrid mpA → walkMask fx/lfx → recurse/self (recursive helper + self-reference) ft/n → frontier/iter fcl/fdist/fprev → frontPos/frontDist/frontPrev cf/rf/clf → fromPos/fromRow/fromCol ct/rt/clt → toPos/toRow/toCol conf/cont → costFrom/costTo df/dr/prev → distFrom/dirDelta/prevDir pd → bestSoFar ift/al/nd/nft → proposals/walkOK/stepCost/newFrontier au/a inside nft → newKeys/merged b/bu inside npool → poolSorted/poolKeys rs/end/z → finalPool/output/outCol t in MAP → tgt The Mazelam call site now reads with names that match the documented contract — Mazelam(costFrom, costTo, ..., distFrom, dirDelta, prevDir). Verified with 432/432 format tests and 459/459 harness tests. Co-Authored-By: Claude Opus 4.7 (1M context) <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
MAZEto the maps library, recreating the BFSMaze_2 body from issue verbatimPer the issue's explicit request, the body is reproduced exactly — parameter names (
mp,st,Cost,Targets,No_Diag,Allowmp,Show_Steps,Cus_Dir,Mazelam) are preserved as-written. A second commit will rename internal LET variables for readability and re-verify against the test suite.Notes on the body's "step count"
Show_Steps=TRUEreturns the body's internalst_value, not pure BFS depth.st_is built asSEQUENCE(ROWS(ft),,0) + SEQUENCE(,COUNTA(xRC),n+1,0)— so it adds the source cell's index within the current frontier to the iteration counter. Example: with 8-way moves, E5 reached from C3 (via D4 at frontier index 2 in iteration n=1) returns2 + 2 = 4, not2. The test case asserts the actual value so any future refactor preserves behaviour.Test layout note
The full-distance-grid test seeds its map at
G3:I5rather thanC3:E5to avoid colliding with the 3×3 spill that originates atA1in the harness.Closes #184
Test plan
dotnet build addin/lambda-boss.slnx— succeededdotnet test addin/lambda-boss.Tests/lambda-boss.Tests.csproj --filter "FullyQualifiedName~LambdaFormatTests"— 432/432 passeddotnet test addin/lambda-boss.AddinTests/lambda-boss.AddinTests.csproj --filter "FullyQualifiedName~LambdaHarnessTests.LambdaTest"— 459/459 passed (including 7 new MAZE tests)=MAZE(yourMap, "C3")should spill the full 8-way distance grid;=MAZE(yourMap, "C3", , "E5", TRUE)should return a 4-way Manhattan distance🤖 Generated with Claude Code