Search code examples
algorithmpath-finding

Algorithm for 'shortest path' with walking agent


I am looking for a shortest path algorithm where the agent (the thing that has to move from start to finish) has only a limited view on the walkable field. Let's say we have a labyrinth with a start and a goal that is tile-based. Something like this: enter image description here The agent then might only be able to see one in each direction (up, down, left, right) but has unlimited memory. As a measurement I want as few steps as possible to reach the goal. Is there an algorithm for that?

And if so is there an algorithm for a more general problem. Let's say: a graph, multiple goals and starts and a function that returns seen nodes, and limited memory?

A solution using a star with total vision: enter image description here


Solution

  • After a while, some ideas and similarities came to my mind.

    It is close to the problem that a Micromouse has to solve most use Flood Fill

    Flood-fill (node, target-color, replacement-color):
     1. If target-color is equal to replacement-color, return.
     2. ElseIf the color of node is not equal to target-color, return.
     3. Else Set the color of node to replacement-color.
     4. Perform Flood-fill (one step to the south of node, target-color, replacement-color).
        Perform Flood-fill (one step to the north of node, target-color, replacement-color).
        Perform Flood-fill (one step to the west of node, target-color, replacement-color).
        Perform Flood-fill (one step to the east of node, target-color, replacement-color).
     5. Return.