To implement this improved polar grid, we’re going to introduce a new Cell subclass in this lesson and then walk through how these new cells will be laid out and subdivided. We’ll finish it all off with one last, mostly aesthetic tweak to make our final maze as tidy as possible.

The PolarCell class

We’ve made it so far by using the existing Cell class, but it’s getting a bit difficult to keep referring to compass directions when they don’t map very intuitively to a polar grid. Also, with adaptive subdivision, some cells may now have two neighbors in the outward direction, and our existing Cell class has no support for that. Let’s create the subclass PolarCell.

Get hands-on with 1200+ tech skills courses.