O'Reilly logo

Mazes for Programmers by Jamis Buck

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating Weave Mazes

It turns out that generating weave mazes isn’t all that different from generating normal mazes. The trick is figuring out how to represent those passages that tunnel underneath the others. Once we’ve got those ironed out, we’ll work on a new Grid subclass with some more to_png tweaks, so we can draw these new tunneling passages.

To get an idea of how these new passages work, let’s take a minute and glance back at Figure 5, A Weave Maze. Pay attention to how and when the passages weave over and under each other. It’s not entirely arbitrary—there are four important rules that make this work unambiguously.

A passage cannot dead-end over or under another passage.
This prevents confusion that could happen when a passage seems ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required