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.
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.
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.