It’s actually quite hard to automatically find the best path for the character (take an item, heal a bit, another item, heal more, take the exit).
We considered that taking the first available route was a decent alternative, since you can decide yourself which objective are available first with the order of the pieces.