Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.






Eight Way Maze

Posted by puz, 07 July 2013 · 395 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.




November 2014 »

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526 27 2829
30      

Recent Entries

Recent Comments

Recent Entries

Recent Comments

PARTNERS