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

Post on 18-Jan-2016

214 views 0 download

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

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”

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

Architecture Considerations

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

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

Throwing Grenades

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

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

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)

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

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)

The Navigation Point

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

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

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

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

Slopes, Stairs, Ladders, etc

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

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

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

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

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

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

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

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?

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

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

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

Scenario 3, 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

Scenario 3, cont.

Putting it all together

• Going back to previous slide

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

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

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

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

Sources

• AI Game Programming Wisdom 2

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