# Understanding Dimensions

Learn how to add dimensions to our mazes, make them 3D or 4D, and apply our maze algorithms to the modified grids.

We'll cover the following

## A general idea of dimensions

All of the mazes we’ve generated to this point have been essentially flat, glued securely to the surface of a plane. Navigating these mazes, regardless of whether they are regular, polar, hex, or triangle grids, we only ever have the option of moving in two dimensions: north or south, east or west, or some combination of those.

It’s true that weave mazes try to escape that constraint a little and do briefly manage to lift portions of their passages above that plane by moving over or under other passages. Still, most of the weave maze remains sadly two-dimensional. We might say that, at best, a weave maze is two-and-a-half-dimensional.

Now, these two-dimensional (or two-and-a-half-dimensional) mazes are sufficient for many things—games like Pac-Man and Doom (to name just two) manage just fine with nothing more than two axes to constrain movement. We’ve done a lot with two-dimensional mazes to this point in this course.

But there’s so much more we can do once we add a third dimension or even a fourth. Cave systems, office blocks, dungeons, Death Stars, time traveling, and portal jumping are just a few examples.

Now, we’re going to look at these higher-dimensional mazes and talk about what exactly that means. We’ll start with three-dimensional regular grids (those whose cells are rectangular in shape), going over the changes that need to be made to our Grid class to accommodate a third dimension, and we’ll talk about how to apply our maze algorithms to these modified grids. Once we’ve got three dimensions working, we’ll briefly look at what higher dimensions do to a maze by considering four-dimensional grids.

## Dimensions in mazes

The word “dimension” in phrases like “two-dimensional” or “three-dimensional” refers to the number of coordinates needed to specify any point within some space. In the case of our two-dimensional mazes, we’ve described those points (or cells) in terms of rows and columns—two coordinates, hence two dimensions.

If we take away all dimensions and remove all coordinates, we've discovered a zero-dimensional space. Such spaces seem exceedingly Zen-like, having no sense of location but only of being. In terms of our mazes, a single cell is a zero-dimensional space because, without the context of other cells, it has no concept of location. We can’t go anywhere from such a freestanding cell. It’s not very exciting by itself, but if we take a bunch of these zero-dimensional cells and stack them together, we can make a one-dimensional grid like this:

Get hands-on with 1200+ tech skills courses.