Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

Eight Way Maze

Posted by puz, 07 July 2013 · 404 views

labyrinth maze php online web-based
Eight Way Maze 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.
Posted Image
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.
Posted Image
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.
Posted Image
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.

February 2015 »

1 234567

Recent Entries

Recent Comments

Recent Entries

Recent Comments