Part 2 of this puzzle ups the ante on the interest level...
The map is to be modified so the centre 3×3 square that gave me a headache in part one is to be closed off, dividing the maze into 4 separate parts with no path between them.
You now have an actor in each quadrant and have to coordinate them to collect all the keys since a key for a door in one quadrant might be in a different quadrant. Interesting!
Here is the visualisation for the solution to this problem.
Now, I think you'll see why the levels of abstraction over a simpler pathfinding algorithm were required.
As in part 1, there is a discovery phase and then the solving phase. The discovery phase is pretty much the same, but there are four origins instead of one.
We now create 4 instances of the Graph class (one for each quadrant) and pass them into the single GraphSolver class. The instance of INodeWalker is now MultiGraphNodeWalker and 4 of them are added to the initial queue, one for each actor's starting point.
The MultiGraphNodeWalker is similar to the other "bots" described in the posts regarding this puzzle, except when it reaches a junction point it will spawn alternate "timelines" if you will. The alternate timelines (not sure this is the right phrase, but I'll run with it) allow the other actors to try out possible moves before the current actor makes its next move.
This approach allows for actors to unlock doors for the other actors in different quadrants.
I may have to revisit some of these posts as while my enthusiasm level is high, my energy levels are sometimes low (this is a side hobby to my full-time job). I feel I could explain some of my reasoning more clearly. Any feedback on this would be appreciated.
