October 10, 2006
Here is a free PDF maze generator that can create mazes of various sizes and complexity, including pretty diabolical mazes that include 3-d crossings...
This form drives some of the options on the maze generator:
Programming in PostScript
When I was a student at Cornell I was a postscript fanatic. PostScript is a complete programming language that happens to be used by many printers, and I found it amusing to write postscript files that rendered differently every time you printed them. One of my favorite creations was a small postscript file that would generate a random labyrinth each time it was printed; it won the Obfuscated PostScript Contest in 1993. Unfortunately, postscript printers are not that common today - instead, everybody uses PDF to prepare files for printing. Although PDF is related to postscript, PDF is not a complete programming language, so for a while I have wanted to write a maze generator for the web that would just generate PDF mazes using a cgi script in some other language.
The result is here: a little cgi/commandline program written in about 150 lines of python which takes advantage of the ReportLab pdf generation library to produce its output.
If you improve the program, please let me know. Enjoy!
Posted by David at October 10, 2006 11:11 AM
Very cool. My 5-year old is on a maze kick. He'll love these. Thanks!
Roger mentioned over email, "If I make a maze 60x60 I get smoke :(".
Basically that's because the maze code puts a 36-point margin around the edge of the paper by default, and throws an exception when a maze ends up being all-margin. Since I figure this blog is read by fellow nerds (like Roger), I didn't bother formatting error messages in my 150-line CGI script: you get to see the stack trace raw.
So how to make really small mazes? You can add "&m=0" to the request URL to make the margin zero points if you like.
this is totally awesome
you should find a way to make a maze with the center as your goal
Cool - you should include a little attribution URL in your output so I can find it again after printing out a bunch of mazes for the kids (and give yourself a little credit).
The "make my maze" bwtton generates an error now. Used to work for me.
Thanks for your program,too easy! I was anticipating HOURS of sitting in front of this computer!
I am curious about your mazes.
I was searching to learn how to make a maze generator myself. I ran across your site.
I have Bible students that I am sure, would love to do these! Maybe I could add a beginning picture and end picture, if allowed.
Another time I will come back and read more. It's late. I would like to put a couple or so of these on my family site, but need to check out your copyright rules, before doing any of these things. Thank you, Carolyn
Thanks, David, for this wonderful maze maker. I enjoy easy-to-use process programs. I am making mazes for church kids.
Ahh I love mazes and so does my son, thanks for this!
Tip: Read this page http://www.inkguides.com/postscript-programming.asp if you are interested in creating your own postscript programs.
My 5 yr old son loves these mazes, and I often print out a few on my lunch hour for him. Now everyday as I say goodbye going to work, he says "Don't forget the mazes", and rattles off the types & sizes he wants that day. Thanks much!
The make my maze button does not work now. Internal server error.
Sorry about that - it was broken by a pair.com upgrade.
It's fixed now!
Feel free to email me at the address on the home page if there's a problem.
These are wonderful and I love to visit the site and generate a maze or two. I am trying them out for my son who is five.
thanks for sharing
Thank you for sharing the source code. I really like the mazes. Can you please post the rewrite rules and .php that allow the pl script to be displayed as a .pdf? I am missing that magic to be able to generate mazes on my web server(non-public).
Thank you again. I just wanted to let you know that i got your cgi working. The issue that i was having is getting cgi working with apache on windows. I added three lines to the httpd.conf file. I added a directory section for the directory that i placed the cgi into with these two commands "Options +ExecCGI" and "AddHandler cgi-script .py". Then i added "ScriptInterpreterSource registry" and "PassEnv PYTHONPATH" and "SetEnv PYTHONUNBUFFERED 1". The information was from http://www.imladris.com/Scripts/PythonForWindows.html.
I would still like to be able to point to a "pdf" file instead of a .py file, however i now have everything working.
Thank you very much. I was able to finally get everything working as it appears to be working on your site. The last piece that i was missing was the rewrite rules. I used these:
RewriteRule ^(.*)\.pdf$ $1.py [T=application/x-httpd-cgi]" inside of a directory section where the python script is stored.
Hello, all I can get is blank white PDF file.
I have windows python, and reportlab installed.
Doing this: pymaze.py -w500 -h500 > test.pdf
but I only get square white pdf page :(
Thanks for help.
I added a '-p' option for specifying the page size as a string. Sizes defined in reportlab.lib.pagesizes (e.g. a4 and letter) are supported.
You don't mention the license under which you're publishing your code. Is it ok to stick my fork on GitHub?
thanks! I'm making an keep-the-little-kids-quiet wedding program for a friend of mine, and your mazes are lovely - I'm going to put a maze or two in with a link for parents to be able to make more...
i want it plz how can i have it ?
Bummer! We've been using and enjoying this for ages but it seems to be broken now.
Thanks for all the fun David!
Your site at davidbau.com no longer will create a maze. Curses!
i have enjoyed it for a long, long time. I have often given your mazes away as gifts to friends to complete.
Can it be fixed?
Sorry about the breakage!
It works again now!
I finally returned to check if you had time to fix mazestoprint.
Thank you, I look forward to many more mazes to share with others.
Make that: printable_mazes.html
Your program is by far the best!
I've been looking for a good maze generator which I need for a design project and your is just perfect, because I am able to easily import the pdf-files into design software like illustrator, so I can manipulate the vectors of the maze. Just perfect for my workflow, thank you very much!
Now I would like to use your code on my private server for bigger output files. In fact I want to use it inside of XAMPP.
Could you please tell me how to set up the maze generation environment right?
I've never worked with cgi scripts before, so I don't know where to place it, so it can be called from the form-elements to write the PDF.
I downloaded your Obfuscated PostScript Contest code(Dynamically Generated maze). It runs great on an older mac(10.4.11) and preview. I'd like to try and get it to work with a CNC router or laser cutter. I think laser cutting by adding a fill command would be straight forward and fairly easy.
Is there an unobfuscated version available with comments?
Is there a parameter that sets the length of the dead end paths?
Culd I use your script from http://davidbau.com/archives/2006/10/10/printable_mazes.html to generate maze for commercial purpose? If I manage to sell some i will tel you way how I monetize it and you will be able to monetize it allso. Can I use it for free to commercial purpose?
Fantastic Maze generator, David!
I am a Dutch teacher and make worksheet to use in my classroom. Does your generator also genetate the solution somewhere?
Could I create mazes for commercial purpose? Can I use it for free to commercial purpose?
Can I use this mazes for commercial purpose? How much costs it?
Can your application show the solutions?
Fantastic Maze generator, David!
Can I use this mazes for commercial purpose? How much costs it? thanks
What about using your maze generator for commercial use, in a book I make for KDP sales? I really want to be 100% careful about that. Thanks. Michael Rush
I have recently discovered your overlapping 3d maze generator and I am very intrigued. I create activity books and have used the typical flat maze generator software as part of the content. I was wondering if you have any terms for allowing use of mazes generated by your unique program in mixed content books for sale. Thank you very much! Tom
Hello, David. My kids love your mazes! Thank you.
I am as well designer and illustrator, and working on books for kids. I'd like to include some mazes there too. Are there any terms for commercial use of your mazes? Thank you. Kind Regards, Helena
I would just like to ask the same question a number of others have asked - are there any restrictions to using the mazes on a commercial basis.
what is the commercial use criteria?
has anyone ever told you you're a-maze-ing? cos that's what you are
Do you allow for Commercial use?
Guys, does anyone try it in amazon KDP books, are there any risks?
Beautiful. But..........answer key???