3

I have a grid like weighted maze and I need to find the shortest path to an entity without having any prior knowledge of the maze.

Algorithms like A* expect priot knowledge and 'jump' around when looking around, but that's not possible when I have a robot for example.

My first thought would be to initially explore the whole maze using BFS and then apply A* on the explored to find the shortest considering the weights as well. But that seems naive.

Can anyone point me to some algorithms that could be a good fit for this problem?

rrebase
  • 3,349
  • 2
  • 16
  • 27

1 Answers1

0

I think the most applicable algorithm for this sort of problem would be Dijkstra's algorithm.

In short, the algorithm starts at some root node, scans all neighbors and choose the node with the shortest path from the root to visit.

A table is kept that contains every node's

  • Shortest path from the root

  • The last node in the path to get to this node

    The shortest path to a node is updated in the table whenever a shorter path is discovered. When your entity is visited, its shortest path will be the shortest path from root->entity, and backtracking through its parents will yield the actual node path. (Here's another video if you're confused).

Community
  • 1
  • 1
Nolan R
  • 11
  • 1