Implementing Better Weaving

Learn how to include the crossings to implement better waving.

Reconditioning the Kruskals class

To implement better weaving, we’re going to add a method to our Kruskals::State class so we can install those crossings in it. That method will be supported by a simple subclass of our WeaveGrid class. With those changes in hand, generating the actual maze will be really straightforward.

So, first, we'll add the add_crossing method just after the merge method in the Kruskals::State class, which is highlighted below.

The updated Kruskals class

Get hands-on with 1200+ tech skills courses.