Upcoming SlideShare
×

# Pathfinding - Part 3: Beyond the basics

1,735 views

Published on

These slides are part of a course about interactive objects in games. The lectures cover some of the most widely used methodologies that allow smart objects and non-player characters (NPCs) to exhibit autonomy and flexible behavior through various forms of decision making, including techniques for pathfinding, reactive behavior through automata and processes, and goal-oriented action planning. More information can be found here: http://tinyurl.com/sv-intobj-2013

Published in: Education, Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,735
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
51
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Pathfinding - Part 3: Beyond the basics

1. 1. INTERACTIVE OBJECTS INGAMING APPLICATIONSBasic principles and practical scenarios in UnityJune 2013Stavros Vassos Sapienza University of Rome, DIAG, Italy vassos@dis.uniroma1.it
2. 2. Interactive objects in games2 Pathfinding Part 1: A* heuristic search on a grid Part 2: Examples in Unity Part 3: Beyond the basics Action-based decision making AI Architectures
3. 3. Pathfinding: Beyond the basics3 Many neat tricks for efficient/nice pathfinding Alternative game-world representations Beyond A* Better heuristics
4. 4. Pathfinding: Beyond the basics4 Many neat tricks for efficient/nice pathfinding Alternative game-world representations Beyond A* Better heuristics
5. 5. Pathfinding: From grids to graphs5 A* works the same in a graph as in a grid Graphs nodes correspond to points in the 2D/3D space We can still use the same heuristics Manhattan, Chebyshev, Euclidean
6. 6. Pathfinding: From grids to graphs6 A* works the same in a graph as in a grid Graphs nodes correspond to points in the 2D/3D space We can still use the same heuristics Manhattan, Chebyshev, EuclideanBut we need togenerate thesegraphs in anautomated way!
7. 7. Pathfinding: From grids to graphs7 Many types of graphs have been studied in video-games as well as in robotics Waypoint graphs Circle-based waypoint graphs Visibility graphs Navigation mesh graphs Probabilistic road maps …
8. 8. Pathfinding: From grids to graphs8 Many types of graphs have been studied in video-games as well as in robotics Waypoint graphs Circle-based waypoint graphs Visibility graphs Navigation mesh graphs Probabilistic road maps … Nice description on Amit’s A* pages, next
9. 9. Pathfinding: From grids to graphs9 Visibility graph Connected obstacle corners Navmesh graph Connected walkable areas
10. 10. Pathfinding: From grids to graphs10 Visibility graph Connected obstacle corners Navmesh graph Connected walkable areasVisibility graph:Often contains toomany edges
11. 11. Pathfinding: From grids to graphs11 Visibility graph Connected obstacle corners Navmesh graph Connected walkable areasNavmesh graph:Several ways tomap to a graph
12. 12. Pathfinding: Navmesh graphs12 Navmesh graph Area decomposed in polygons One or more graph nodes per polygon Polygon center movement One node at thecenter of each polygon Nodes connected ifthey are in adjacentpolygons
13. 13. Pathfinding: Navmesh graphs13 Navmesh graph Area decomposed in polygons One or more graph nodes per polygon Polygon edge movement One graph node at thecenter of each edgebetween adjacentpolygons Don’t have to go to thecenter of a polygon
14. 14. Pathfinding: Navmesh graphs14 Navmesh graph Area decomposed in polygons One or more graph nodes per polygon Polygon vertex movement Graph nodes and edgesat each as the polygons Helpful for movingaround an obstacle,following its edges
15. 15. Pathfinding: Navmesh graphs15 Navmesh graph Area decomposed in polygons One or more graph nodes per polygon Pick your own hybridcombination! Here: graph nodes bothat nodes of polygonsand the middleof edges of polygons
16. 16. Pathfinding: Navmesh graphs16 Navmesh graph Widely used in video games! Supported natively in Unity Pro after version 4 A lot of passionate supporters :)
17. 17. Pathfinding: Navmesh graphs17 “Fixing pathfinding once and forall” by Paul Tozour(2008) at www.ai-blog.net Pathfinding on waypoint graphs vs navmesh graphs 1. Some graphs require too many waypoints
18. 18. Pathfinding: Navmesh graphs18 “Fixing pathfinding once and forall” by Paul Tozour(2008) at www.ai-blog.net Pathfinding on waypoint graphs vs navmesh graphs 2. More difficult to make “smooth” realistic paths
19. 19. Pathfinding: Navmesh graphs19 “Fixing pathfinding once and forall” by Paul Tozour(2008) at www.ai-blog.net Pathfinding on waypoint graphs vs navmesh graphs 3. More difficult to handle dynamic obstacle avoidance
20. 20. Pathfinding: Navmesh graphs20 “Fixing pathfinding once and forall” by Paul Tozour(2008) at www.ai-blog.net Pathfinding on waypoint graphs vs navmesh graphs Other interesting observations in the article
21. 21. Pathfinding: Beyond the basics21 Many neat tricks for efficient/nice pathfinding Alternative game-world representations Beyond A* Better heuristics
22. 22. Pathfinding: Beyond A*22 Incremental versions of A* Real-time/Any-time versions of A* Hierarchical versions of A* Any-angle pathfinding Diverse character pathfinding Cooperative pathfinding
23. 23. Pathfinding: Beyond A*23 Incremental versions of A* Real-time/Any-time versions of A* Hierarchical versions of A* Any-angle pathfinding Diverse character pathfinding Cooperative pathfinding Nice article by Alex Nash at AiGameDev.com, next
24. 24. Pathfinding: Beyond A*24 Any-angle pathfinding Theta* Combining visibility graphs and the power of A* on grids Simple extension based on A* Here: 8-connected nodes at the corners of each cell
25. 25. Pathfinding: Beyond A*25 Finding better/nicer paths vs post-processing paths
26. 26. Pathfinding: Beyond A*26 Finding better/nicer paths vs post-processing pathsManhattan distanceheuristicChebyshev distanceheuristic
27. 27. Pathfinding: Beyond A*27 Finding better/nicer paths vs post-processing pathsManhattan distanceheuristicChebyshev distanceheuristicSlower, but easierto improveFaster, but moredifficult to improve
28. 28. Pathfinding: Beyond A*28 Any-angle pathfinding with Theta* Very similar to A* Search from the start node Open list of nodes to visit Closed list of visited nodes Expand a node by lookinginto neighbors Compute and store f(s’) for each of the neighbors ofexpanded node s: f(s’) = g(s’) + h(s’)
29. 29. Pathfinding: Beyond A*29 Any-angle pathfinding with Theta* Very similar to A* Search from the start node Open list of nodes to visit Closed list of visited nodes Expand a node by lookinginto neighbors Compute and store f(s’) for each of the neighbors ofexpanded node s: f(s’) = g(s’) + h(s’) But, do a trick in computing g(s’) and the parent of s’!
30. 30. Pathfinding: Beyond A*30 Any-angle pathfinding with Theta* Expand node s Look into neighbors of s, e.g., node s’ Consider two cases when computing g(s’)
31. 31. Pathfinding: Beyond A*31 Any-angle pathfinding with Theta* Expand node s Look into neighbors of s, e.g., node s’ Consider two cases when computing g(s’)Option 1: g(s’) = g(s) + c(s,s’)
32. 32. Pathfinding: Beyond A*32 Any-angle pathfinding with Theta* Expand node s Look into neighbors of s, e.g., node s’ Consider two cases when computing g(s’)Option 1: g(s’) = g(s) + c(s,s’)Option 2: g(s’) = g(p) + c(p,s’),where p is the parent of s!
33. 33. Pathfinding: Beyond A*33 Any-angle pathfinding with Theta* Expand node s Look into neighbors of s, e.g., node s’ Consider two cases when computing g(s’)Option 1: g(s’) = g(s) + c(s,s’)Option 2: g(s’) = g(p) + c(p,s’),where p is the parent of s!If the Option 2 is better alsoupdate the parent!
34. 34. Pathfinding: Beyond A*34 Any-angle pathfinding with Theta* Essentially remove unnecessary grid-like steps, usingvisibility information Simplifying and smoothing as you go!
35. 35. Pathfinding: Beyond A*35 Any-angle pathfinding with Theta* Essentially remove unnecessary grid-like steps, usingvisibility information Simplifying and smoothing as you go!
36. 36. Pathfinding: Beyond A*36 Incremental versions of A* Real-time/Any-time versions of A* Hierarchical versions of A* Any-angle pathfinding Diverse character pathfinding Cooperative pathfinding Nice resources available!
37. 37. Pathfinding: beyond A*37 AAAI 2008 tutorial on path planning Part 1: Advances in Path Planning by Sven Koenig http://webdocs.cs.ualberta.ca/~nathanst/aaai_tut1.pdf Any-angle pathfinding Field D*, Theta* Incremental versions of A* FSA*, AA*, LPA*, MTAA*, D*Lite Real-time versions of A* LRTA*, RTAA*
38. 38. Pathfinding: beyond A*38 AAAI 2008 tutorial on path planning Part 2: Abstraction in Pathfinding by Nathan Sturtevant http://webdocs.cs.ualberta.ca/~nathanst/aaai_tut2.pdf http://webdocs.cs.ualberta.ca/~nathanst/pathfinding.html Abstraction for minimizing memory Used in BioWare’s Dragon Age Generalized Cooperative pathfinding CA*, WHCA*, PRA*, CPRA*
39. 39. Pathfinding: beyond A*39 Beyond A*: Speeding up pathﬁnding throughhierarchical abstraction by Daniel Harabor http://harablog.files.wordpress.com/2009/06/beyondastar.pdf Hierarchical pathfinding HPA* Dealing with diversity HAA* Beyond grids ProbabilisticRoad Maps
40. 40. Pathfinding: beyond A*40 AAAI 2008 tutorial on path planning Part 3: Map Representations & Geometric Path Planningby Michael Buro http://webdocs.cs.ualberta.ca/~nathanst/aaai_tut3.pdf Polygon-based Free space decompositions TA*: Triangulation A* TRA*: Triangulation reductions A*
41. 41. Pathfinding: Beyond the basics41 Many neat tricks for efficient/nice pathfinding Alternative game-world representations Beyond A* Better heuristics
42. 42. Pathfinding: Better heuristics42 True distance memory based heuristics (TDHs) Main idea based on precomputing useful information Store true distance between selected pairs of nodes Use these to calculate admissible estimates for any pair Different variations How to chose the initial pairs to pre-compute How to calculate heuristic values from pre-computedpairs Recent IJCAI-09 paper and SOCS-10 paper
43. 43. Pathfinding: Better heuristics43 Differential heuristic Pick a set of “canonical” nodes Compute true distance between every node and thecanonical nodes For dist(a,b) look into all canonical nodes c and take asestimate the max value of |dist(a,c)-dist(b,c)|
44. 44. Pathfinding: Better heuristics44 Differential heuristic Pick a set of “canonical” nodes Compute true distance between every node and thecanonical nodes For dist(a,b) look into all canonical nodes c and take asestimate the max value of |dist(a,c)-dist(b,c)| Admissible! Intuition: think of just one canonical state c dist(a,b)+dist(b,c) has to be greater or equal than dist(a,c)otherwise this would have been stored as a shorter route The max out of many canonical states is a better lowerbounda bc
45. 45. Pathfinding: Better heuristics45 Canonical heuristic Pick a set of “canonical” nodes Compute true distance between the canonical nodes Compute true distance between every node and the mclosest canonical nodes For dist(a,b) look into all pairs of m canonical nodes c1close to a and m canonical nodes c2 close to b, andtake as estimate the max value of|dist(c1,c2) - dist(a,c1) - dist(b,c2)|
46. 46. Pathfinding: Better heuristics46 Border heuristic and portal-based heuristic Domain is partitioned in regions Borders between regions Portals connect regions Store true distancebetween pairs of portals Portal-based searchthat breaks pathfindinginto sub-problems
47. 47. Pathfinding: Compress Path Databases47 Another neat idea in a recent AIIDE-11 paper Ultra-Fast Optimal Pathﬁnding without Runtime Search
48. 48. Pathfinding: Compress Path Databases48 Another neat idea in a recent AIIDE-11 paper Ultra-Fast Optimal Pathﬁnding without Runtime Search Pre-computing and store all paths! Compress Path Databases that bring the data tomanageable size Compared to A* runtime speedup reaches two ordersof magnitude It has been tested over maps of Baldur’s Gate
49. 49. Pathfinding: Compress Path Databases49 “Path coherence” The shortest paths from a current node to any target ina remote area share a common first move Think of going from Rome to a destination in any city inwestern Europe Most probably all shortest paths from a specificstarting point to any of these destinations have to passthrough some fixed landmarks, e.g., a major intersection CPDs store this information for every node in the graph
50. 50. Pathfinding: Compress Path Databases50 CPDs compress this information for every node inthe graph using boxes of destinations that can be“directed” in the same way1. Starting from here2. Going to here
51. 51. Pathfinding: Compress Path Databases51 CPDs compress this information for every node inthe graph using boxes of destinations that can be“directed” in the same way1. Starting from here2. Going to here3. You need to go NE!
52. 52. Pathfinding: Compress Path Databases52 CPDs compress this information for every node inthe graph using boxes of destinations that can be“directed” in the same way One starting node For all possible destinations Compute the next move that youneeds to be performed Make this map Store it by compressingregions