55 comments

[ 4.1 ms ] story [ 144 ms ] thread
> 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.

There are already several online maze generator whose output is free for commercial use. What's so special about this one?

(comment deleted)
Which ones? Can you show an example of such a maze generator? It’s hard to compare otherwise.
Probably the author being annoyed by their website being recommended by someone for generating "passive income" based on someone else's labor.
I agree and it's certainly their perogative and one should respect it.

That said, how are people using this to generate any income at all? Printing out and selling mazes? How big can that market be?

Doesn't have to be special, the creator just wants to be compensated if you're using it for commercial use. You're free to go to other creators if you want.
Comprehensive generator with many styles and output options. TIL that mazes with a short solution path are called "Elitist".

Maze generation algorithms [1] are great fun. This book chapter [1] details the development of my 198X IOCCC maze generation submission re-discovering Eller's algorithm.

[1] https://en.wikipedia.org/wiki/Maze_generation_algorithm

[2] https://tromp.github.io/maze.html

Guess triangular and hexagonal grids are somewhat rare, but not exactly unknown. I remember the Programming Clojure book included a maze-generator that was shown for both square and hex grids (and could probably be easily modified for triangles as well?).

Surprisingly the linked generator does not seem to have any choice of different maze algorithms? I guess it only uses one of the perfect algorithms then, meaning all possible mazes have equal probability. Those tend to be pretty boring. I think the biased algorithms often create more interesting mazes.

(EDIT: I see after reading some other comments here and the Help page that the E and R values can be set to create more biased mazes which sounds useful.)

Jamis Buck's Maze algorithm page is a great resource and the book he wrote about programming mazes is even better. It has nice visualizations of how the biases from different not perfect algorithm creates different patterns of mazes.

https://www.jamisbuck.org/mazes/

Implementing and visualizing different maze algorithms is probably my favorite kind of exercise when trying some new programming language (or things like game frameworks/libraries). Most of the algorithms are very easy, so there are no distractions from trying to get the logic right, but there are still some data-structures to play with and a bit more weight than Hello World.

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?
Change E to 0
Thanks! That is way better.

Although maybe instead of that just being an input field under "Advanced", its effect should be explained for us folk who don't know what those settings mean.

It's on the "help" page, as is R.
Yeah, it is - but people don't often dig into help pages when they see something they find odd... they just close the page.
Excellent

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?

I discovered this book in an HN comment, it's only right I post it here as well http://www.mazesforprogrammers.com/
Haven't read the book, but the author wrote multiple blog entries about different maze generation algorithms[0] prior to its publishing which I found personally useful.

[0] http://weblog.jamisbuck.org/archives.html (the maze posts date from early 2011)

I have it and it was a really enjoyable read! Gave me some good ideas for a game I was working on.
This is an enjoyable book! It's an easy read, and the code is nice and straightforward. It avoids getting lost in any programming weeds, revealing the maze algorithms and techniques clearly.

I used what I learned to add a maze generator to the game I'm working on! So far only one level makes use of it (since most levels are better off being hand-crafted), but I have ideas for some other interesting levels that might use the maze generator.

What’s E and R?
From the help page:

    E-value - Controls the elitism tendency of the generation algorithm. An elitist maze has a short solution relative to the size of the maze, while a non-elitist has a solution going through a larger portion of the maze.
    R-value - Controls the river tendency of the generation algorithm. A maze with a high river factor has few but long dead ends, while one with a low river factor will have many short dead ends.
(comment deleted)
This, I presume, it'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!

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.

And for that extra HN cred, it's written in Rust (which you are free to ignore if you're not into RIIR, but this is in fact a rewrite of an earlier Python project of mine)!

[1]: https://github.com/moses-palmer/labyru

Is there a web demo?
No, you'll have to exercise your own CPU I'm afraid!
Your readme is pretty thin on information. How do I even run this? How can I configure the parameters?
A kind soul contributed an update to the README---basically the output of `cargo run --bin maze-maker -- --help.

I guess today's lesson is: do promote your personal project even when it's semi-arsed, because people on the Internet are mostly kind and will help you improve your documentation!

A friend of mine does coding live streams on Twitch. It's pleasantly surprising how many randos (who become internet friends) will help out with your projects.
Many human engineers get happy chemicals from helping people! Also many humans!
Basic question: What would be the simplest way to "digitize" one of these mazes i.e. turn them into a programmable data structure (2D array, matrix, etc.) for example to use as input into a maze solver/RL demo?
The main application is actually a thin wrapper around a library that does exactly that, so the best way would be to not perform the final step of turning the data structure into an image.
What are the methods available?

--method <METHOD> The initialisation method to use

Yeah, I was hoping the `clap` macros would perform some unthinkable magic there... I will have to update the help with a listing.

In the mean time, have a look here[1] for the possible values.

[1]: https://github.com/moses-palmer/labyru/blob/7b92be3ae279a9ff...

`clap` does have magic for enums:

  use clap::{Parser, ValueEnum};

  #[derive(ValueEnum, Debug, Clone)]
  pub enum Foo {
    Bar,
    Baz,
  }

  #[derive(Parser, Debug)]
  #[command(author, version, about, long_about = None)]
  pub struct Args {
    /// description
    #[arg(short = 'f', long = "foo", value_enum, default_value = "bar")]
    foo: Foo,
  }
The output of `--help` will look like:

  -f, --foo <FOO>  description [default: bar] [possible values: bar, baz]
This is with clap >= 4.4 with the derive feature.
I'd love to see a screenshot before downloading/installing.
My personal favorite is the triangular shape, with outer side length set to 200 and inner side length set to 197.
Been a while since I saw a FB like button on a real website
When I was 21, I had a friend who could draw these by hand. Crazy. It always blew me away. I was amazed. She'd know how to draw them and know they only had 1 solution too, but she'd have to figure out the solution IIRC. It freaked me out. Aside from that, she was "normal", relatively. Mad respect :)
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.

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.

I sure wish I still had the source code.

Heh, I wrote a pascal program to draw the mandelbrot set. To make a print out I wrote a fortran program to convert it to postscript. I printed it on a giant lab printer that took up a wall of the lab. It normally printed 60+ pages a minute. My 300 dpi mandelbrot keep it busy for a few minutes, the lab attendant was about to kill the job, I asked for a bit of patience and everyone in the lab came to look at the result.
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.

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.

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's surprisingly easy to see the solution almost immediately. Hard to unsee once you get into the mindset of looking for it.