September 11, 2008

Python Maze Generator

Chris Stakor of Mucho Mazes wants, of course, mucho mazes, and asked for help making our PDF maze generator output multiple mazes at once. Sure thing! The updated python maze generator code now accepts a page count argument.

Here is the form:

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

Warning that if you try more than about a dozen pages on my website, my CPU limits will stop the script from completing. Of course, you can run the script on your own server if you want hundreds of pages.

It occurs to me that I never bothered to write something to draw solutions. Any volunteers?

Posted by David at September 11, 2008 09:07 AM

Hi Dave,

These mazes are really cool! Thanks for sharing the simple python code.

I am working on a solution generator. It currently solves the maze and adds a page of solution per maze, redrawing the maze but with the solution. It is a recursive solution that has problems with very dense mazes (I got it to work down to cell size of 9 on my PowerMac). Also, the drawing of solution path leaves a lot to be desired, especially when cross and/or curve are turned on. I plan to work on those issues next.

I will post it on my web site for now.

Tom Krauss

Posted by: Tom Krauss at October 1, 2008 11:04 PM


If anyone is interested I got solve to work for all the supported modes... please contact me if you want to share. There is a "mini-blog" of sorts on my web site with a few details and examples.

- Tom

Posted by: Tom Krauss at October 11, 2008 11:19 PM

Note, With David's permission I've made the modified code available at

Posted by: Tom Krauss at November 7, 2008 10:34 PM

Hi again!

I've attempted a few clean ups to the "drawsolution" function, making it clearer and more compact. Actually, it may be a little too compact to easily follow :-) but it is my attempt at following the style of the original - and it's at the very least better than what I first posted.

See my web page for the latest.

Tom K.

Posted by: Tom K. at November 12, 2008 10:57 PM

Thanks so much for these mazes! I used them (with lots of other things) for a friend's "kids wedding activity book" and at my own kids' urging also made an "older kids reception activity book" - they are so attractive and, with the crossings, challenging even for older kids! Thanks for making them available!

After making those mazes and seeing how beautifully they turned out, I have a request - I have made a repeating design from your mazes

With your permission I would like to make and sell fabric at Spoonflower in four or five colorways with that design. I think it would make attractive fabric! Would that be okay with you? I would credit you and link to your program. I see that the program itself is copyrighted; If you would rather I didn't use a modified maze for commercial activity, I won't, and will take down the picture I posted.

Thanks again!


Posted by: kelly at July 24, 2013 08:22 AM
Post a comment

Remember personal info?