Adding a Third Dimension
Recall back in Chapter 2, Automating and Displaying Your Mazes, when we first worked on the code behind the grid, we implemented the prepare_grid method using a two-dimensional array. That’s not just coincidence—that’s exactly what determined the geometry of our grid! We’ll add a third dimension to the grid by adding a third dimension to that array.
If it were that easy, this would be a very short chapter. The good news, though, is that the other changes are minor collateral damage related to that array modification. The cells need to be told about their new up/down neighbors, the grid needs to know how to iterate over cells in the other levels, and so on.
It’s really not too bad, and best of all is that once we’ve ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access