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

Introducing Masking

The idea behind masking is really pretty simple. The basic metaphor is that our grid is essentially a very low-resolution image, where each cell is like a single pixel. Turning any of these pixels off marks them as off-limits, so our maze algorithm (whichever one we’re using) will never try to walk there.

In the following figure, the cell in the southeast corner has been turned off. The resulting maze, then, omits that cell entirely.

images/maze-from-modified-grid.png

Conceptually, that’s really all there is to it! In practice, though, there are some things to consider, and some consequences that follow from mucking with the geometry of our grids like this.

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