Implementing a Mask

Learn to create a Mask class that will encapsulate the on-off state of each cell in our grid.

The Mask class

Let’s create a Mask class that will encapsulate the on-off state of each cell in our grid. That is to say, for each cell in the grid, our mask should be able to tell us whether or not it should be included in the maze. The following implementation does this by keeping a separate two-dimensional array of Boolean values, where false means the corresponding cell is “off the grid.” Let's look at the code below.

Get hands-on with 1400+ tech skills courses.