Your Turn

Masking is a powerful technique that opens up many possibilities. We’ve only scratched the surface in this chapter. Take some time and experiment with it, and see what else you can come up with. Here are some ideas to get you started.

Geometric Designs

Our mazes so far have all been fit into grids bounded by rectangles. Experiment with using masks to shoehorn a maze into a triangle or a circle.

Multi-State Masks

In our Mask class, we used an array of Boolean values to indicate where cells can and cannot exist. If, instead of Booleans, we use integers, we end up with the possibility of multi-state masks, allowing us to describe multiple different regions within the grid. One use for this is to split the grid into multiple pieces, run ...

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.