There is a bug in braiding that, when a maze has no dead ends, causes an exception to be thrown. I suspect this is because braiding doesn't check before proceeding that there are dead ends.
It is easily reproduced in either of the following ways for a Maze m:
The problem turned out to be in RNG.shuffle when trying to shuffle an empty collection.
I was previously performing a subtraction on the size method, which returns an unsigned integer type.
There is a bug in braiding that, when a maze has no dead ends, causes an exception to be thrown. I suspect this is because braiding doesn't check before proceeding that there are dead ends.
It is easily reproduced in either of the following ways for a
Maze m
:m.braidAll().braidAll()
m.makeUnicursal().braidAll()