Your Turn
It’s been said that if you stick to the rules, you miss all the fun. When it comes to mazes, at least, there appears to be some truth to that. Knowing which rules to bend (or even break!) can open entire floodgates of possibility.
We focused in this chapter on breaking the rules that forbid self-intersection—that is, allowing passages to intersect themselves. We worked through braiding mazes by removing dead ends, and then further complicated things by dropping pits of molten lava in the middle of our lovely shortest path. We looked at how Dijkstra’s algorithm can compensate for these traps and obstacles—these weights—and give you the most efficient (least expensive) path around them. We implemented weave mazes and a way to draw them ...
Get Mazes for Programmers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.