Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

38
Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Transcript of Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Page 1: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scott Lindner

10/6/04

Pathfinding and Navigational Systems, cont.

Page 2: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Outline

• 2.5: How to get more out of a navigation system

• Architecture Considerations• High-Level Benefits • Low-Level Benefits

• 2.6: Hunting down the player• Choose destinations wisely• Search “intelligently”

Page 3: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Using navigation for more than just route-finding

• When/where to throw a grenade?

• Automatically climb a ladder or jump a gap?

• What locations are useful to hide behind, or lean around?

Solution:

•embed additional information directly into navigational data

•automatically detect it during a preprocessing step, or encode it by hand

Page 4: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Architecture Considerations

additional AI layer specializes in movement, steering, animation, and other low-level details that decision maker is not designed for

Page 5: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

High-Level Point Selection and Pathfinding

• Any data that AI can easily look at is potentially usable

• Finding cover and combat tactics– “Bounding Overwatch”– More details later…

• Throwing grenades– Not practical to calculate trajectories during the game– Encode possible throws directly into the system

» must be evaluated from all points to all possible targets

Page 6: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Throwing Grenades

Page 7: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Throwing Grenades

Agent queries navigation system to find closes allowable point

• Decision making code will instruct agent how to get to the calculated spot and how to throw his grenade

Page 8: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Biasing Edge Cost

• Normally cost = distance

• Can make agent avoid a given edge by adding to its cost

• Stop “cutting corners”• SOF2

– Avoid areas where comrades die

Page 9: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Biasing Edge Cost

ParentPoint = OpenList.GetFromOpenList()

For each edge from ParentPoint

Switch Edge.type()

Case FLY_EDGE:

If ( actor.CanFly() )

Edge.cost = actor.FlyBiasCost()

OpenList.AddToOpenList(Edge)

Page 10: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Low-Level Animation and Steering

• Path usually handed down as abstract series of points

• Embedded information will give AI knowledge to perform various behaviors

• Dynamic movement– Jumping over crevice

• Eliminates need to script behavior

• Allows special movement types to be added, all existing combat behavior will automatically make use of it

Page 11: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

The Navigation Point

• Provide discrete locations to space where AI agents can move to/from

• Use spatial volumes as discussed previously

• Test for reachability and “openness”• Sphere (of influence)

Page 12: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

The Navigation Point

Page 13: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Obstacle Visibility

• Vertical tests (height)• Used to find locations to hide behind• Run collision tests, until you don’t hit anything • Previous C and D

• Side to side test• Near a corner?• Run collision tests perpendicular• Previous A and B

Page 14: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Navigation Edge

• Points alone not sufficient for navigation

• Adding additional information into edges is very useful

• Certain characters might have features making traversal possible/impossible

– Size» Maximum size can be calculate by running collision

tests and anything <= that can pass through

Page 15: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Situations

• Over a crevice – jump? fly?

• Navigation points in the air• Only applicable to agents who can fly, ignored by

others

• Over an obstacle - vault? Jump?

• Through a movable obstacle• Open a door• Move a box

Embed all animations directly into respective edge

Page 16: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.
Page 17: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.
Page 18: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Movable Objects

• Retry collision test after removing/relocating object

• If next test succeeds, edge is still valid

• Any complex sequence of behaviors

(reach out, pull door open, step back, etc)

all embedded in navigation system

Page 19: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Slopes, Stairs, Ladders, etc

• Slopes tell about surroundings– Vertical = ladder/rope– Otherwise = stairs/slope

Page 20: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

2.6: Hunting Down the Player in a Convincing Manner

• Goal is to have NPC convincingly chase and hunt a player

– Spotted by guard, etc.

• Today’s gamers expect intelligent behavior

• Problem is AI can cheat, following too direct of a path

– Leads to “unfair” results

Solution: ensure that the agent explores and looks like it’s trying to find it’s nonvisible target by a process of search, rather than direct path

Page 21: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Enabling a Range of Behaviors

• Must be able to control scope of the search

• Bumbling/wandering agent• Agent who searches with purpose, decisively

• These allow us to control how quickly discovery occurs and how direct the resulting path is

Page 22: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Approach

• Agent’s objective: get closer to player over time– Utilize pathfinding

• Requires a given destination– Usually places agent closer to player– Simple idea is to head to players current location

» does not produce good gameply(player hiding)

Solution: come up with more interesting destinations

Page 23: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Application

• Requirements• Pathfinding system is capable of establishing

relatively quickly the accessibility of the world• Method is iterative, therefore requires multiple calls

to give desire behavior• Knowledge of hunting character and target player• Facility of “line of sight” – can we see the player?

• Basic approach is to periodically generate new search destination over time

• destinations actually intermediate destinations

Page 24: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Possible Problems?

• Since process is iterative, could lead to lots of calls being made and many paths being constructed (in theory)

• Solution:

(see requirements)

• generation of search destinations is a relatively infrequent even in AI terms.

•Unlikely necessary to calculate a new character search destination more frequently than 1 character / second [McLean02].

•Intervals lasting several seconds will be perfectly acceptable for many games

Page 25: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

3 Possible Scenarios

• During each update decide which of the 3 currently apply

The player is visible

The player was recently seen

The player has never been seen

Page 26: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scenario One: The Player is Visible

• Hunting behavior is over

• Transition into an appropriate attacking behavior

• Look for cover within weapon range?• Move to that spot?• Engage in hand to hand combat?

Page 27: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scenario Two: The Player Was Recently Seen

• NPC does not currently have line of sight• Move towards last seen player location

– Leads to “fun” gameplay• Trick agent by circling an object

• Need to maintain “last seen” location• Store time and location

• Important to clear “last seen” when agent begins moving on its route

• Otherwise agent might fall into states that are inappropriate due to out-of-date info

Page 28: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scenario 3: The Player Has Never Been Seen

• Must create a search location, rather than extract one from the AI system

• Randomly generate a location somewhere close to player (within a certain radius)

– Cheap to do, but not very purposeful or guided

• Solution: same idea, but slightly different

Page 29: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scenario 3, cont.

• Generate two random parameters– Direction heading

• Direction vector to true player’s location• Then alter vector subject to a certain window of

variance

– Straight line distance to travel• Lies within given interval

» Consider the interval a multiplier of actual distance to player

Page 30: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scenario 3, cont

Page 31: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scenario 3, cont

• Keep in mind that since destination is randomly generated, it might not actually be accessible

• Route to closest location that IS accessible• Existing pathfinding system already offers this functionality• Also, route to destination wont be straight line, but again,

built into pathfinding system

• Must update vision more frequently than generation of destinations in case we see the player

Page 32: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Scenario 3, cont.

Page 33: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Putting it all together

• Going back to previous slide

Page 34: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Enabling a Range of Behaviors

• Must be able to control scope of the search

• Bumbling, wandering, accidental, discovery of player, search path that is purposeful, efficient, direct

• These allow us to control how quickly discovery occurs and how direct the resulting path is

Page 35: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Putting it all together

• Purposeful characters that appear to find the player quickly given values of Smin and Smax close to 1.0 with a small Φ.

• “Bumbling” agents will require values for Φ, Smin, and Smax far from 1.0

Page 36: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Extending to 3D

• Easily extend to 3D by generating points inside 3D cones

• Cost very insignificant and approach still very successful

• Relative sizes of regions to be searched will vary non-linearly

• (i.e. halving the radius of the cone will more than halve the search space)

• Agent will find character twice as fast

Page 37: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Other Considerations

• Agent must always be reconsidering its current destination

• As to not ignore a player who runs directly in front of him on his way to a destination

• Static players/dynamic players » Dynamic means MANY more calls

• Can respond to other percepts• Sounds• Other teammates

Page 38: Scott Lindner 10/6/04 Pathfinding and Navigational Systems, cont.

Sources

• AI Game Programming Wisdom 2

• Mclean, Alex, “An Efficient AI Architecture Using Prioritized Task Categories,” AI Game Programming Wisdom, Charles River Media, 2002