path planning part i: search space representation part ii: table lookup path finder path iii:...

36
Path Planning Part I: Search Space Representat ion Part II: Table Lookup Path Finde r Path III: Convincing Hunting Ref: AIWisdom 2

Upload: letitia-burns

Post on 20-Jan-2016

232 views

Category:

Documents


0 download

TRANSCRIPT

Path Planning

Part I: Search Space RepresentationPart II: Table Lookup Path FinderPath III: Convincing Hunting

Ref: AIWisdom 2

Spring 2005 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, …)

Spring 2005 3

Task Decomposition

Search Space Representations: ways to define the waypointsSearch AlgorithmsExtension: mixed with local algorithm …

Spring 2005 4

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 perfo

rmance and memory overheadAssumption: 2D, or 3D hovering at fixed height Full 3D: flying, swimming characters

Spring 2005 5

Introduction

All search spaces are graphs: nodes and edgesProblem definition (Path Optimality): given two points A and B, find the least expensive path from A to BRemarks: not always the shortest [consider swamp] Must consider agent movement capability

[size, open door, swim, climb, …]

Spring 2005 6

Character-dependent Paths

Spring 2005 7

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

Spring 2005 8

Types of Representation

Regular grid (square, hexagonal)Corner graphWaypoint graph [circle-based]Space-filling volumeNavigation Mesh [triangle or poly-based]

Understand the pros and consSmooth technique (string-pulling)Hierarchical representation (thousands of waypoints …)

Spring 2005 9

Example Scene

Spring 2005 10

Regular Grid

Simplest way: grid of squares, rectangles, triangles, hexagons, …Large number of grid cell (large memory footprint)Easy for “random-access lookup”

Spring 2005 11

Regular Grid (cont)

Quality of path 4-way access Allow diagonal

Spring 2005 12

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

Spring 2005 13

Alternative: Chase the Point

Instead of tracking along the path, the agent chases a target point that is moving along the pathStart with the target on the path ahead of the agentAt 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

Spring 2005 14

Chase the Point Demo

Spring 2005 15

Remark

Grid, though seemingly can be implemented as arrays, should be implemented as (directed) graph: path can be directional

AB

CD

Spring 2005 16

Corner GraphWay 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 …

Spring 2005 17

Waypoint Graph

Similar to corner graph; but waypoints are usually placed in the middle of rooms and hallwaysAlso suffer from the O(n2) complexity issue Works well in human architecture; tend to work poorly in large rooms and open terrainUsually require hand-tuning by level designer to perform well

Spring 2005 18

Circle-based Waypoints

Try to resolve the O(n2) complexityAdd to each way point a radius parameter: indicate the amount of open space around itGenerate edges between node pairs whose circles overlapWorks well in open terrain, but in angular environment circles may not fill well (shown in figure)

Spring 2005 19

Space-Filling Volumes

Ways of generation: drop-and-grow; merge from gridWorks better (cp. circle-based) for angular environment

Spring 2005 20

NavMeshCover the game world with convex polygonsHandles indoor and outdoor terrain equally wellRequire storage of large number of polygonsConvexity is required because …Triangulation, trapezoidalization

Spring 2005 21

Modified String-Pulling

Besides eliminating unnecessary points on the path, path points can move along the link (shared edge) between two nodes

Spring 2005 22

Hierarchical Representation

Break the navigation problem into levels [library in NYC to a diner in Seattle]

Key step: identify zones; cluster nodes in search graphIndoor scene: use portal information

Navigation Set Hierarchy

Spring 2005 24

Introduction

Developers are spending more resources in the attempt to deliver interesting and complex AI behaviorBasic functions like path-finding should be cheapPrecomputing navigation accomplishes this, with a price: memory

Spring 2005 25

Basics: The Transition Table

Table requires n2 entries

Spring 2005 26

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 anotherInterface nodes: the connective boundaries between navigation setsInterface set

Spring 2005 27

Example

Spring 2005 28

Constructing the Hierarchy

Partitioning by automated means is a complex problem !Objective: keep the number of interface nodes as low as possibleIdentify “choke points”

Spring 2005 29

Complete Path Planner

Source & goal in same NavSet: trivialFour-step solution Source to boundary set Tier-2 paths: interface nodes Boundary set to Target From combinations; select the one with l

east costPerformance depends on the number of interface nodes in the source and

goal sets only

Spring 2005 30

Example

A3A6

A7

C3

C5C7

Spring 2005 31

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?

Hunting Down the Player in a Convincing Manner

Spring 2005 33

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 plan

ner generate a shortest-path may let the player feel cheated

Interesting game play: lure the NPC into regions then double back to escape

Spring 2005 34

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

Spring 2005 35

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

Spring 2005 36

Scenario Three

Create intermediate destination to approach the player

Generate random direction and travel distance

Successive application