A* Path Finding Ref: A-star tutorial.

15
A* Path Finding Ref: A-star tutorial

description

The Problem start target wall Find a path of lowest cost Given

Transcript of A* Path Finding Ref: A-star tutorial.

Page 1: A* Path Finding Ref: A-star tutorial.

A* Path FindingRef: A-star tutorial

Page 2: A* Path Finding Ref: A-star tutorial.

The Problem

start target

Given

Find a path of lowest costwall

Page 3: A* Path Finding Ref: A-star tutorial.

TerminologyNode

Parent node; current nodeTraversal cost: F = G + H

G: movement cost from starting point

H: heuristic cost to the target (e.g., Manhattan distance)

Open list & closed list Closed: traversal cost

already determined

Heuristics: (wiki) experience-based techniques for problem solving, learning, and discovery.

Manhattan distance

Page 4: A* Path Finding Ref: A-star tutorial.

A* AlgorithmTake the node of lowest cost from open list; switch it to closed list; name it current nodeFor its reachable and non-closed neighbors: If not in open list, add them. Make current node

their parent. Evaluate costs G & H. Else (already in open), revise parent using G.

update cost.Stop when: target is added to closed list Open list is empty (fail to find target). No path

Page 5: A* Path Finding Ref: A-star tutorial.

(0,0)

(0,4)

(6,0)

(5,2)(1,2)

ExampleOpen: (0,1),(0,2),(0,3),(1,1),(1,3),(2,1),(2,2),(2,3)

Closed:(1,2)

Page 6: A* Path Finding Ref: A-star tutorial.

(0,0)

(0,4)

(6,0)

(5,2)(1,2)

Open: (0,1),(0,2),(0,3),(1,1),(1,3),(2,1),(2,3)Closed: (1,2),(2,2)

10+10<14

Page 7: A* Path Finding Ref: A-star tutorial.

Open: (0,1),(0,2),(0,3),(1,1),(1,3),(2,3),(1,0),(2,0)Closed: (1,2),(2,2),(2,1)

(0,0)

(0,4)

(6,0)This neighbor is NOT addeddue to the “cut-corner” constraint

Page 8: A* Path Finding Ref: A-star tutorial.
Page 9: A* Path Finding Ref: A-star tutorial.

Finally,

Page 10: A* Path Finding Ref: A-star tutorial.

ComparisonDijkstra, Best-first, A* Ref: url

Page 11: A* Path Finding Ref: A-star tutorial.

Dijkstra AlgorithmRepeatedly examines the closest not-yet-examined vertex, adding its vertices to the set of vertices to be examined. expands outwards from the starting point until it reaches the goal.guaranteed to find a shortest path from the starting point to the goal

Page 12: A* Path Finding Ref: A-star tutorial.

Best-First SearchInstead of selecting the vertex closest to the starting point, it selects the vertex closest to the goal. (Greedy) Best-First-Search is not guaranteed to find a shortest path.

Page 13: A* Path Finding Ref: A-star tutorial.

Dijkstra better than Best first

Dijkstra Best-first

Page 14: A* Path Finding Ref: A-star tutorial.

A* combines the advantages of both

Page 15: A* Path Finding Ref: A-star tutorial.

Implementation (google code)