Skip to content

Conversation

@bobnik
Copy link
Collaborator

@bobnik bobnik commented Jan 1, 2026

Adds a new Maze shape that generates drawable mazes for sand tables. Supports four grid types and seven algorithms, with continuous path drawing via Chinese Postman algorithm.

Grid types:

  • Rectangle - traditional cartesian grid
  • Circle (Polar) - concentric rings with configurable wedge doubling
  • Hexagon - pointy-top hex grid
  • Triangle - delta grid with alternating triangles

Algorithms:

  • Wilson, Backtracker, Prim, Kruskal (all grid types)
  • Division, Sidewinder, Eller (rectangle only)

Drawing options:

  • Show entry/exit arrows (finds hardest path through maze)
  • Show solution path (spline-smoothed)
  • Circle mazes: segment or arc walls
  • Algorithm-specific tweaks: straightness, horizontal bias, branch level

Technical highlights:

  • Unified grid abstraction layer for algorithm portability
  • Chinese Postman + Eulerian trail for continuous single-path drawing

Attribution:

  • codebox/mazes by Rob Dawson (MIT) - polar/hex/triangle grid implementations
  • Jamis Buck's maze algorithms (CC BY-NC-SA 4.0) - Wilson's algorithm reference
  • See src/features/shapes/maze/LICENSE for full details

Test plan

  • Verify all 4 grid types render correctly
  • Test each algorithm on its supported grid types
  • Verify entry/exit arrows display and connect properly
  • Test solution path rendering with arrows
  • Confirm seed produces reproducible results
  • Test dimension changes update transformer proportionally

@bobnik bobnik changed the title Feature/mazes mazes! Jan 1, 2026
@jeffeb3
Copy link
Owner

jeffeb3 commented Jan 8, 2026

This is really fun! What's your favorite combination? I wouldn't mind changing the default to something more interesting, like the hexagons and the backtrack algorithm. I also think 12 is a little small for a default. It's working very fast on my computer.

@jeffeb3
Copy link
Owner

jeffeb3 commented Jan 8, 2026

Have you tried drawing any of these? I like that the spline solution is drawn after drawing the walls. It looks like a good experience (instead of just a picture).

I wonder if the order it draws things gives away the answer though. At some point, it's probably drawn everything between the start and the end. I guess I'll have to just try it. Nothing I can think of to make that better...

@jeffeb3
Copy link
Owner

jeffeb3 commented Jan 8, 2026

This may be a problem. It's no issue for me. But our code is MIT and can be completely reused by anyone (including for profit companies like sisyphus industries). I see the license at the bottom of the website, but I'm not sure what you used from that site. The text is obviously copyright protected and allowed with that license. The actual algorithms should be fair game, as long as you didn't copy/paste the code. I'm not a lawyer though.

Thinking about this some more, it may be possible to still include this with that license, and anyone else that wants to copy/paste code from sandify just can't copy the maze feature.

@bobnik
Copy link
Collaborator Author

bobnik commented Jan 9, 2026

@jeffeb3

  • Re: better default maze, I changed it to 20 x 20, backtracker. I think rectangle is the better choice for the default than hexagon (more traditional), but it's just a personal preference.
  • Re: order giving away the solution. With the rectangular maze, I do see it roughly walking some of the solution as it builds the maze, but it's not super obvious. The other shapes don't seem to do this. I think it's ok?
  • Re: Jamie Buck attribution. I reviewed this carefully, and while I definltely looked at that page for initial inspiration, the code doesn't adapt anything from his implementation. Additionally, the maze algorithms are publicly available and also in the Rob Dawn's MIT-licensed source (which we have in LICENSES), so I removed the Buck references.

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.

3 participants