Great question @solideserenade!
Due to the way we’re constructing the path, the isPath
and isExplored
flags will both be set to true for nodes that end up being part of the path.
When it comes time to color our coordinate labels, we’re using a set of else-if statements to perform various checks on all the nodes in the grid.
These statements evaluate from top to bottom and if one happens to return true then the rest get skipped.
This means that we have to check for isPath
first in our labeller. Otherwise, we would only ever see the explored nodes and not the found path.
As an experiment, try switching these two else-if statements and you’ll see that the path no longer shows up.
I hope that help.