This is a piece of python code that has the ability to generate massive mazes. (I created it on the 13th of June 2013 as a one-day project - I was curious as to how big a maze I can get) The algorithm requires extreme depths of recursion, amounts beyond what Python can handle, so I had to bypass this problem by creating my own stack and writing the content of it onto the disk when it became too large.
For extremely large mazes, the program has the ability to bypass main memory limitations by cutting the maze up into sectors. It stores the unused sectors onto the disk and keeps the active ones in the memory. After a few passageways have been created, the algorithm is stuck to working on passageways in a specific part of the maze and does not need to load the sectors from the disk for some time.
Code:
- The code can be found in a git repository here.
Sample output
- 30 by 30
- 500 by 500
- 3 000 by 3 000 - This is about the largest size I recommend opening in a browser. Better machines can handle it but a laptop might not.
- 10 000 by 10 000 - The maze I thought was large enough to be the largest..
- 20 000 by 20 000 - After a search of the internet I found that the largest maze out there that can be easily found and downloaded was created by Walter Pullen and is 10 001 by 10 001 pixels. Being beaten by a single pixel is not something I was prepared to accept. ; ) Watch out, it can take a while to open this image. Reached a maximum recursion depth of around 22 470 000.
All links from the CV