1 / 36

Chapter 7. A* Pathfinding

Chapter 7. A* Pathfinding . 2013/04/18. A* Pathfinding . For most pathfinding problems, A* is the best choice The A* algorithm is efficient, but it can consume quite a few CPU cycles. Straight-line distances to Bucharest Arad 366 Bucharest 0 Craiova 160 Drobeta 242 Eforie 161

makayla
Download Presentation

Chapter 7. A* Pathfinding

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 7. A* Pathfinding 2013/04/18

  2. A* Pathfinding • For most pathfinding problems, A* is the best choice • The A* algorithm is efficient, but it can consume quite a few CPU cycles.

  3. Straight-line distances to Bucharest Arad 366 Bucharest 0 Craiova 160 Drobeta 242 Eforie 161 Fagaras 176 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 Oradea 380 Pitesti 100 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 Zerind 374 Romania with Step Costs in km

  4. Greedy Best-First Search • Greedy best-first search expands the nodes that appears to be closest to the goal • Evaluation function = Heuristic function • f(n) = h(n) = estimated best cost to goal from n • h(n) = 0 if n is a goal • e.g., hSLD(n) = straight-line distance for route-finding function GREEDY-SEARCH( problem ) returns a solution, or failure return BEST-FIRST-SEARCH( problem, h )

  5. Greedy Best-First Search Example

  6. Analysis of Greedy Search • Complete? • Yes (in finite space with repeated-state checking) • No (start down an infinite path and never return to try other possibilities) • (e.g., from Iasi to Fagaras) • Susceptible to false starts Isai  Neamt (dead end) • No repeated states checking Isai  Neamt  Isai  Neamt   (oscillation)

  7. Analysis of Greedy Search (cont.) • Optimal? No • (e.g., from Arad to Bucharest) • Arad → Sibiu → Fagaras → Bucharest • (450 = 140+99+211, is not shortest) • Arad → Sibiu → Rim → Pitesti → Bucharest • (418 = 140+80+97+101) • Time? best: O(d), worst: O(bm) • m: the maximum depth • like depth-first search • a good heuristic can give dramatic improvement • Space? O(bm): keep all nodes in memory

  8. A* Search • Avoid expanding paths that are already expansive • To minimizing the total estimated solution cost • Evaluation function f(n) = g(n) + h(n) • f(n) = estimated cost of the cheapest solution through n • g(n) = path cost so far to reach n • h(n) = estimated cost of the cheapest path from n to goal function A*-SEARCH( problem) returns a solution, or failure return BEST-FIRST-SEARCH( problem, g+h)

  9. Straight-line distances to Bucharest Arad 366 Bucharest 0 Craiova 160 Drobeta 242 Eforie 161 Fagaras 176 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 Oradea 380 Pitesti 100 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 Zerind 374 Romania with Step Costs in km (remind)

  10. A* Search Example 140 118 75 140 99 151 80 Arad 366 Bucharest 0 Craiova 160 Drobeta 242 Eforie 161 Fagaras 176 Giurgiu 77 Hirsova 151 Lugoj 244 Mehadia 241 Oradea 380 Pitesti 100 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Zerind 374 211 99 145 97 80 80 80 80

  11. Straight-line distances to Bucharest Arad 366 Bucharest 0 Craiova 160 Drobeta 242 Fagaras 176 Lugoj 244 Mehadia 241 Oradea 380 Pitesti 100 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Zerind 374 Romania with Step Costs in km 192

  12. Admissible Heuristic • A* search uses an admissible heuristic h(n) • h(n) neveroverestimates the cost to the goal from n • n, h(n) h*(n), where h*(n) is the true cost to reach the goal from n (also, h(n)  0, so h(G) = 0 for any goal G) • e.g., h(n) is not admissible • g(X) + h(X) = 102 • g(Y) + h(Y) = 74 • Optimal path is not found! • e.g., straight-line distance hSLD(n) never overestimates the actual road distance

  13. Admissible Heuristic (cont.) • e.g., 8-puzzle • h1(n) = number of misplaced tiles • h2(n) = total Manhattan distance • i.e., no. of squares from desired location of each tile • h1(S) = • h2(S) = • A* is complete and optimal if h(n) is admissible 8 3+1+2+2+2+3+3+2 = 18

  14. Admissible Heuristics • 8-puzzle • h1(n) = number of misplaced tiles • h2(n) = total Manhattan distance • i.e., no. of squares from desired location of each tile • h1(S) = • h2(S) = 8 3+1+2+2+2+3+3+2 = 18

  15. Effect of Heuristic Accuracy on Performance

  16. 7.1 Defining the Search Area

  17. Simplifying the search area

  18. 7.2 Starting the Search • A* algorithm • Evaluation function f(n) = g(n) + h(n)

  19. 7.3 Scoring, Initial values 1+3=4 1+3=4 1+3=4 1+4=5 1+4=5 1+5=6 1+5=6 1+5=6

  20. Examining tile(5,6) 2+3=5 1+3=4 1+3=4 1+3=4 1+4=5 1+4=5 2+4=6 1+5=6 1+5=6 1+5=6

  21. Examining tile(5,5) 2+3=5 1+3=4 1+3=4 1+3=4 1+4=5 1+4=5 2+4=6 1+5=6 1+5=6 1+5=6

  22. Examining tile(5,4) 2+4=6 2+4=6 2+3=5 1+3=4 1+3=4 1+3=4 2+4=6 1+4=5 1+4=5 2+4=5 1+5=6 1+5=6 1+5=6

  23. Examining all tiles with cost 5 2+4=6 2+4=6 2+3=5 1+3=4 1+3=4 1+3=4 2+4=6 1+4=5 1+4=5 2+4=6 1+5=6 2+5=7 1+5=6 1+5=6 2+5=7

  24. Examining all tiles with cost 6 3+4=7 3+3=6 3+5=8 3+5=8 2+4=6 3+5=8 2+4=6 2+3=5 1+3=4 1+3=4 1+3=4 2+4=6 3+5=8 1+4=5 1+4=5 2+4=6 3+5=8 1+5=6 2+5=7 1+5=6 1+5=6 2+5=7 2+6=8 2+6=8 2+6=8 2+6=8

  25. 7.4 Finding a Dead End

  26. 7.5 Terrain Cost • Total Cost from Start = Cost from Start + Terrain Cost • Score = Total Cost from Start + Heuristic

  27. 3+3=6 1+3=4 3+3=6 1+4=5 1+4=5 1+5=6 1+5=6 1+5=6

  28. Calculating the lowest-cost path • The lowest-cost path

  29. Figure 7-25. Continuous environment node placement

  30. 7.6 Influence Mapping • Influenced by the enemy firing zone

  31. Influenced by the number of kills

More Related