Simple Maze Generation using Coldfusion
Tuesday February 1, 2011 ·
1875 views ·
2 comments
As a kid, I always loved to solve mazes as well as try to create them using graph paper and a trusty #2 pencil. My mazes were never terribly complex but that did't matter, they were fun to build and fun to try and solve. Fast forward 20+ years and I still enjoy mazes but had not't given much thought in way of creating them. Luckily I ran across Jamis Buck's blog, the { buckblogs :here } and was amazed to see all of the different algorithms that could be used to create mazes. Jamis does an awesome job of putting the algorithms into simple terms with lots of pictures, a visual demo (in JS) and some code samples in ruby. His post inspired me to try my hand at implementing some in Coldfusion. I started with the Recursive Backtracking algorithm, which at a high level it goes something like this:
The following snippet shows how you would implement the algorithm using an iterative approach. ** The code for this was written to be compatible with Railo, thus the method signatures do not look as complete as Adobe's CF9 implementation Out of the algorithms that Jamis covered, this was one of the fastest and also the easiest to implement. In my next post, I will cover Kruskal's algorithm which builds a randomized (minimum) spanning tree Here is the working code for this example: Coldfusion Maze Generation Code Updated: Here is a 35 x 35 cell maze generated from the from the above code. ![]() Comments"What happens is not as important as how you react to what happens." - Ellen Glasgow
Recent Reads |




No demo or screenshots of the final product?
Yeah i guess an example or demo would be nice. =)
I updated the post with a sample maze created from the code. Shamefully, I haven't back ported my example to work on the (really old) version of CF my shared hosting is on. The best I have for a demo is the code that you can download and run locally.