I’ve been spending a little while with scalatest and flatspec to push the implementation of my maze algorithm a bit further, both in terms of the scala style I’m using and in terms of the interface I’m providing.
One of the benefits was taking this little number:
which initialises the grey list used in building out the maze with the neighbours of the first cell chosen. This is the result of some slightly unfocused hacking, as you can tell from the fact it checks with each neighbour has already been added to the list. I replaced it with this:
and arguably I don’t actually need a method call at all any more – although the method name does indicate what I’m trying to do. I also switched to using Vector – at most each one will have 4 elements. I could only do this because I was using neighbours as an immutable structure, for example:
I was going to claim that the improvement in initGreyListNeighbours made the code simpler … but that process call takes a little bit of parsing. One for later!