October 10, 2006

Printable Mazes

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...

Maze Options

This form drives some of the options on the maze generator:

width in points
height in points
cell size
pages
curvy straight
crossings not

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 Source

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
Comments

Very cool. My 5-year old is on a maze kick. He'll love these. Thanks!

Posted by: Robert W. Anderson at October 12, 2006 11:24 AM

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.

Posted by: David at October 17, 2006 01:57 PM

this is totally awesome

you should find a way to make a maze with the center as your goal

Posted by: jesse at January 16, 2007 05:55 AM

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).

Posted by: Patrick Surry at April 23, 2007 01:31 PM

The "make my maze" bwtton generates an error now. Used to work for me.

Posted by: Tom at October 17, 2007 12:56 AM

Fixed!

Posted by: David at October 30, 2007 05:05 AM

Thanks for your program,too easy! I was anticipating HOURS of sitting in front of this computer!

Posted by: Ning at March 10, 2008 07:56 PM

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

Posted by: Carolyn at September 12, 2008 01:46 AM

Thanks, David, for this wonderful maze maker. I enjoy easy-to-use process programs. I am making mazes for church kids.

Posted by: Gayle at October 28, 2008 06:13 PM

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.

Posted by: Stuart at January 2, 2009 08:26 AM

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!

Posted by: Ken at April 20, 2009 03:46 PM

The make my maze button does not work now. Internal server error.

Posted by: Jenny at October 29, 2009 12:11 AM

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.

Posted by: David at October 30, 2009 08:07 PM

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
diane

Posted by: Diane at December 16, 2010 04:40 PM

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).

Posted by: Mitchell at May 3, 2011 03:12 PM

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.

Posted by: Mitchell at May 4, 2011 08:54 AM

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:
"RewriteEngine on
RewriteRule ^(.*)\.pdf$ $1.py [T=application/x-httpd-cgi]" inside of a directory section where the python script is stored.

Posted by: Mitchell at May 4, 2011 02:53 PM

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.

Posted by: Jan Daniel at June 9, 2011 05:28 AM

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?

https://github.com/akaihola/pypdfmaze

Posted by: Antti Kaihola at October 13, 2011 03:49 AM

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...

Posted by: kelly at May 11, 2013 09:37 PM

i want it plz how can i have it ?

Posted by: keem at September 30, 2013 03:53 PM

Bummer! We've been using and enjoying this for ages but it seems to be broken now.

Thanks for all the fun David!

:)

Posted by: Dean at May 8, 2014 10:47 PM

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?

Bob

Posted by: Bob at May 12, 2014 08:32 PM

Sorry about the breakage!

It works again now!

Posted by: David at May 12, 2014 09:43 PM

David,

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.

Bob

Posted by: Bob at May 16, 2014 06:15 PM

David,

Make that: printable_mazes.html

Your program is by far the best!

Bob

Posted by: David at May 16, 2014 06:20 PM

Hello David,

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.

Alex

Posted by: Alex at August 8, 2014 11:01 PM

David,

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?

John

Posted by: John at October 24, 2016 02:25 PM

Hallo David.
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?

Grettings,
Jakub Miłek

Posted by: Jakub at September 13, 2017 12:36 PM
Post a comment









Remember personal info?