I am currently working on a project that requires us to help a character find an object within a maze, which is run through a GUI.
However, we can only access the nodes neighboring the location that the character is at, so we are unable to pre-process the maze and build the shortest path before moving the character.
We are given a helper method that returns the number of rows + cols (disregarding the walls that block the way) that each of the neighboring nodes are from this object we are looking for, so I have implemented a DFS and included a min-heap to first traverse the path with the neighbor that has the lowest distance.
Our problem is that sometimes, the path with the lowest distance may reach a dead-end, and we have to wait for it to complete an entire DFS of that branch until it can go back and search another path. Is there an algorithm that could circumvent this problem and reach the object in fewer steps?