360 likes | 415 Views
Path Planning. Part I: Search Space Representation Part II: Table Lookup Path Finder Path III: Convincing Hunting Ref: AIWisdom 2. Taxonomy. Local path finding For dynamic environment [characters in motion, obstacles moved by characters] potential energy, steer, … Global path planning
E N D
Path Planning Part I: Search Space Representation Part II: Table Lookup Path Finder Path III: Convincing Hunting Ref: AIWisdom 2
Taxonomy • Local path finding • For dynamic environment [characters in motion, obstacles moved by characters] • potential energy, steer, … • Global path planning • For static environment • Graph-based search algorithm (Dijkstra, A*, BFS, …)
Task Decomposition • Search Space Representations: ways to define the waypoints • Search Algorithms • Extension: mixed with local algorithm …
Search Space Representations • Analogy: C++ STL: algorithms (sort, find, copy, …) work on various container classes (vector, list, …) • Path finding: • algorithms (BFS, DFS, Dijkstra, A*,…) • Search space representation: … • Choice of representation has great impact on performance and memory overhead • Assumption: 2D, or 3D hovering at fixed height • Full 3D: flying, swimming characters
Introduction • All search spaces are graphs: nodes and edges • Problem definition (Path Optimality): given two points A and B, find the least expensive path from A to B • Remarks: • not always the shortest [consider swamp] • Must consider agent movement capability [size, open door, swim, climb, …]
Search Space Generation • Options: • manually created by level designer • Automatically generated by programs • “The AI is broken in your level because you put the path node in the wrong place …” jeopardize the workflow
Regular grid (square, hexagonal) Corner graph Waypoint graph [circle-based] Space-filling volume Navigation Mesh [triangle or poly-based] Understand the pros and cons Smooth technique (string-pulling) Hierarchical representation (thousands of waypoints …) Types of Representation
Simplest way: grid of squares, rectangles, triangles, hexagons, … Large number of grid cell (large memory footprint) Easy for “random-access lookup” Regular Grid
Quality of path 4-way access Allow diagonal Regular Grid (cont)
String-Pulling • Line-of-sight test: remove Pn if Pn+1 is visible from Pn-1 • Can be very expensive • Use Catmull-Rom spline to create a smooth curved path
Alternative: Chase the Point • Instead of tracking along the path, the agent chases a target point that is moving along the path • Start with the target on the path ahead of the agent • At each step: • Move the target along the path using linear interpolation • Move the agent toward the point location, keeping it a constant distance away or moving the agent at the same speed • Works best for driving or flying games
B A D C Remark • Grid, though seemingly can be implemented as arrays, should be implemented as (directed) graph: path can be directional
Way points placed at convex corners of the obstacles O(n2) complexity to determine edges in the graph Create sub optimal path Character walk very close to the wall (unnatural) different sized character requires different set of waypoints … Corner Graph
Similar to corner graph; but waypoints are usually placed in the middle of rooms and hallways Also suffer from the O(n2) complexity issue Works well in human architecture; tend to work poorly in large rooms and open terrain Usually require hand-tuning by level designer to perform well Waypoint Graph
Circle-based Waypoints • Try to resolve the O(n2) complexity • Add to each way point a radius parameter: indicate the amount of open space around it • Generate edges between node pairs whose circles overlap • Works well in open terrain, but in angular environment circles may not fill well (shown in figure)
Space-Filling Volumes • Ways of generation: drop-and-grow; merge from grid • Works better (cp. circle-based) for angular environment
Cover the game world with convex polygons Handles indoor and outdoor terrain equally well Require storage of large number of polygons Convexity is required because … Triangulation, trapezoidalization NavMesh
Modified String-Pulling • Besides eliminating unnecessary points on the path, path points can move along the link (shared edge) between two nodes
Hierarchical Representation • Break the navigation problem into levels • [library in NYC to a diner in Seattle] • Key step: identify zones; cluster nodes in search graph • Indoor scene: use portal information
Introduction • Developers are spending more resources in the attempt to deliver interesting and complex AI behavior • Basic functions like path-finding should be cheap • Precomputing navigation accomplishes this, with a price: memory
Basics: The Transition Table Table requires n2 entries
Hierarchy • Navigation set: a self-contained collection of nodes that requires no links to external nodes in order to complete a path from one internal nodes to another • Interface nodes: the connective boundaries between navigation sets • Interface set
Constructing the Hierarchy • Partitioning by automated means is a complex problem ! • Objective: keep the number of interface nodes as low as possible • Identify “choke points”
Complete Path Planner • Source & goal in same NavSet: trivial • Four-step solution • Source to boundary set • Tier-2 paths: interface nodes • Boundary set to Target • From combinations; select the one with least cost Performance depends on the number of interface nodes in the source and goal sets only
A6 C3 C7 A3 C5 A7 Example
Memory Optimization • In the transition table, instead of storing node indices (which can be large and requires more bits), store edge indices (edge that lead to the node) I doubt this will work. How to know which node a particular edge leads to?
Introduction • Require NPCs to convincingly chase and hunt down the player • When a guard has spotted the player, he begins pursuit • Routing player’s position to a path planner generate a shortest-path may let the player feel cheated • Interesting game play: lure the NPC into regions then double back to escape
Facility: • Know the positions of target player and hunting character (NPC) • Visibility test from NPC to player • Three scenarios • Player is visible (by the NPC) • Player was recently seen • Player has never been seen
Scenarios Scenario One: • Change from hunting state to attack state Scenario Two: • NPC moves to the last seen player location, should be stored by game engine
Create intermediate destination to approach the player Generate random direction and travel distance Successive application Scenario Three