TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Maze Generator

174 pointsby sandebertover 1 year ago

15 comments

andrewlaover 1 year ago
When my kids were smaller, they would often request that I make mazes for them on restaurant placemats, etc. Since I was working in crayon, many of the traditional maze generation algorithms, which relied on removing walls, were inapplicable.<p>What I found, though, was that you can construct mazes additively, while ensuring a single unique solution, by looking at the dual of the maze. If you start by drawing a shape with an entrance and an exit, you can start at any wall (including the borders, and just start drawing lines out that do not intersect previous lines. Basically you get a forest-like structure.<p>The neat thing is that this method can generate all mazes, and you can look at any generated maze, and if you just look at the dual (the tree-like graph of the walls) it&#x27;s surprisingly easy to see the solution almost immediately. Hard to unsee once you get into the mindset of looking for it.
moses-palmerover 1 year ago
This, I presume, it&#x27;s the perfect opportunity to promote my own maze generator[1], which incidentally is a Real Application that you can run on your own computer, and the output of which you own!<p>Like the linked application, it supports triangular, rectangular and hexagonal grids, and different generation algorithms, which can be combined for various areas of the final maze. It also supports background and mask images to colourise rooms and provide a shape for the maze, as well as a small selection of effects to apply. The output format is either SVG or PNG.<p>And for that extra HN cred, it&#x27;s written in Rust (which you are free to ignore if you&#x27;re not into RIIR, but this is in fact a rewrite of an earlier Python project of mine)!<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;moses-palmer&#x2F;labyru">https:&#x2F;&#x2F;github.com&#x2F;moses-palmer&#x2F;labyru</a>
评论 #38735358 未加载
评论 #38734188 未加载
评论 #38735834 未加载
评论 #38733712 未加载
评论 #38735284 未加载
rippeltippelover 1 year ago
&gt; the mazes from this site are not free to use for commercial purposes. If you are planning to use them in something you will sell, you need to get a commercial license.<p>There are already several online maze generator whose output is free for commercial use. What&#x27;s so special about this one?
评论 #38734325 未加载
评论 #38734211 未加载
评论 #38733269 未加载
评论 #38733600 未加载
NeutralForestover 1 year ago
I discovered this book in an HN comment, it&#x27;s only right I post it here as well <a href="http:&#x2F;&#x2F;www.mazesforprogrammers.com&#x2F;" rel="nofollow noreferrer">http:&#x2F;&#x2F;www.mazesforprogrammers.com&#x2F;</a>
评论 #38733706 未加载
评论 #38735946 未加载
评论 #38733821 未加载
ourmandaveover 1 year ago
One of several blog posts on roguelike game writing, Bob Nystrom wrote a maze generator.<p><a href="https:&#x2F;&#x2F;journal.stuffwithstuff.com&#x2F;2014&#x2F;12&#x2F;21&#x2F;rooms-and-mazes&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;journal.stuffwithstuff.com&#x2F;2014&#x2F;12&#x2F;21&#x2F;rooms-and-maze...</a>
analog31over 1 year ago
Back in high school, I wrote a maze generator in BASIC, that printed the maze using ASCII characters. Then I figured out the biggest maze that would fit on a sheet of 132 column green bar paper, and submitted the job to the mainframe computer.<p>Next morning, I got an angry rebuke from the teacher. The mainframe operator had killed my program after it had run for quite some time, assuming it was an endless loop. It just turns out my program had some astronomical order of complexity.<p>I sure wish I still had the source code.
评论 #38746892 未加载
thih9over 1 year ago
My personal favorite is the triangular shape, with outer side length set to 200 and inner side length set to 197.
评论 #38736146 未加载
keepamovinover 1 year ago
When I was 21, I had a friend who could draw these by hand. Crazy. It always blew me away. I was amazed. She&#x27;d know how to draw them and know they only had 1 solution too, but she&#x27;d have to figure out the solution IIRC. It freaked me out. Aside from that, she was &quot;normal&quot;, relatively. Mad respect :)
trompover 1 year ago
Comprehensive generator with many styles and output options. TIL that mazes with a short solution path are called &quot;Elitist&quot;.<p>Maze generation algorithms [1] are great fun. This book chapter [1] details the development of my 198X IOCCC maze generation submission re-discovering Eller&#x27;s algorithm.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Maze_generation_algorithm" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Maze_generation_algorithm</a><p>[2] <a href="https:&#x2F;&#x2F;tromp.github.io&#x2F;maze.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;tromp.github.io&#x2F;maze.html</a>
评论 #38733277 未加载
codingdaveover 1 year ago
The solutions seems overly linear - make a large maze, and the solution does meander a bit, but I generated a dozen or so and never found one that actually traversed much of the maze. Is that intentional?
评论 #38733152 未加载
rekadoover 1 year ago
I prefer this one, which looks nice and generates crossings: <a href="https:&#x2F;&#x2F;github.com&#x2F;daleobrien&#x2F;maze">https:&#x2F;&#x2F;github.com&#x2F;daleobrien&#x2F;maze</a>
tantalorover 1 year ago
Been a while since I saw a FB like button on a real website
albert_eover 1 year ago
Excellent<p>Is there any curated collection of such generators that includes math and word problems for various grade levels as well? Or crosswords and other small games etc?
injulyover 1 year ago
I remember writing a maze generator for a personal game project (a Nuclear clone-like). The wikipedia article for maze generation [1] was surprisingly helpful, though I ended up using something closer to a pseudo-random walker.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Maze_generation_algorithm" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Maze_generation_algorithm</a>
brapover 1 year ago
What’s E and R?
评论 #38733841 未加载
评论 #38733800 未加载