Eight Way Maze
labyrinth maze php online web-based
I decided to write a maze drawing program where the paths extend in eight directions. So I first designed the appearance with a free CAD program, as I did with Beads Maze, a program I wrote about 2 weeks ago.
Next I wrote the low level display routine, which draws the paths according to the internal connectivity. At first I was planning to round the center bends, but I decided to leave the corners pointy for simplicity. I also wrote a test page in PHP that increments a counter each time I click on a button. Since there are 256 patterns to test, this really came in handy while debugging my code. At one point it showed me that a trim intersection function I wrote was fundamentally flawed. I spent a whole day rewriting it.
The final step was to cut and paste a maze generating code I wrote before and tailor it to this one. This step wasn't too difficult except for a perplexing bug -- it was not until I broke up a long conditional expression into many small steps that I realized that in PHP, == has a higher precedence than &. I wonder if I'm the only person who finds it counterintuitive that a bitwise AND operation is performed after equality comparison.
Above image is the final result. All in all, there were places in the code that felt heavy and laborious but chipping away on it every day eventually got me to the finish. Here is the link to the Eight Way Maze program. Thank you for reading.