Pymaze stuff

I worked on a version of pymaze.py, a really cool and succinct python program that generates random mazes. (See David Bau's blog entry for context) I added a "solve" option. Click here for the modified version, initially posted 11/7/08 with David's permission. [Updated on 11/12/08, after code "clean up"] Send me an email if you would like to know more about it.


10/5/08 update: got solution to draw with "curve" turned on (example PDF output). Next step: "cross".


10/10/08 update: got cross working - see an example (I also reduced the width of the soln path to be the same as the walls for now). The recursive solution still has an issue with very small cell sizes (failing at stack depth of 995 on my machine - about half the time for cell = 10) which is due to stack overflow. Not sure what to do about it ...


10/11/08 update: Made "solve" non-recursive, so now the small cell sizes are completing without any problems (although they take a while to compute :-). Here's an example with cell size of 2.5 points - note, the file is almost 1 MB! cell=2.5 example


6/29/09: Got the following email about running Pymaze on Windows... here was my response... let me know if anyone has success running it!

On Jun 29, 2009, at 4:42 PM, Tim Bohmann wrote:

Tom,

Thanks for contributing a solver to David Bau's maze generator. I'm curious to know if I can run the file you created as a standalone program with the python interpreter. I am interested in having it run on my windows machine without having to create a web page. Is this possible? I'm sure it is, but I have little experience using python.

Thanks,

Tim Bohmann San Antonio, TX

Hi Tim,

It should be possible to run pymaze on windows. You will need to download the ReportLab PDF Library for whichever version of python you are running. http://www.reportlab.org/downloads.html

I run it on Mac OS X (UNIX-like) like this:

python pymaze_with_soln.py --cross=0 --curve=0 --solve=1 --cell=10 > foo.pdf

"cell" is the size of cells in "points", with the default setup of 8.5 x 11 inch page with 72 points per inch and 36 point margins. The other options (cross, curve, solve) are boolean flags with 0 false and 1 true. See the source file for other possible command-line options. David Bau programmed all the options - I only added "solve" - and made it so you could call it from a browser or the command-line. I am not sure how to redirect a file in Windows... the program outputs to stdout but you could probably edit it to save to a named file instead.

Have fun!

- Tom


7/4/09: After a bit more back-and-forth with Tim, it turns out the redirection on Windows requires running "python" with a "-u" option:

python -u pymaze_with_soln.py --cross=0 --curve=0 --solve=1 --cell=10 > foo.pdf