Transcript
Page 1: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Dude, where’s my

Warthog?From

Pathfinding to

General Spatial

Competence

Damián IslaBungie Studios

Page 2: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

What this talk is about

• Halo2: What we did. What we didn’t. What worked. What you never see but we assure you is there.

• How does the work we do parallel that done in other fields?

• Where we go from here.

Page 3: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

The Grand Question

What constitutes general spatial competence?

Lots of things.

Also, depends on who you ask.

Page 4: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Sources

• Psychology– Cognitive: Spatial vision,

reference frames, spatial relations, cognitive maps

– Developmental: object permanence / search

– Design: Affordances

• Ethology– Place-learning– Landmark navigation vs.

dead-reckoning

• Cognitive neuroscience– Neural Maps– Hippocampal place-cells– Reaching / grasping

• AI– Pathfinding– Semantic networks

• Robotics– Spatial feature extraction– Self-localization– Map-learning

• Game/Embodied AI– Practical, robust whole-brain

implementations

Page 5: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

The Halo Approach

• AIs are given a “playground”, within which they are allowed to do whatever they want.

• The designer defines the flow of battle by moving the AI from one playground to another.

• The designer’s time is precious

• Relatively little spatial information is explicitly entered by the designers.

Page 6: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Problems Solved in Halo2• Static Pathfinding

– Navigation mesh (ground)– Waypoint network (airborne)– Raw pathfinding– Path-smoothing– Hint integration (jumping, hoisting, climbing)– Static scenery-based hints– Static scenery carved out of environment mesh

• Static feature extraction– Ledges and wall-bases– Thresholds– Corners– Local environment classification

• Object features– Inherent properties (size, mass)– Oriented spatial features– Object behaviors (mount-to-uncover, destroy cover)

• Dynamic Pathfinding– Perturbation of path by dynamic obstacles– “Meta-search” / Thresholds / Error stages– Obstacle-traversal behaviors

• Vaulting, hoisting, leaping, mounting, smashing, destroying

• Path-following– Steering on foot (with exotic movement modes)– Steering a vehicle (e.g. ghost, warthog, banshee)

• Interaction with behavior– What does behavior need to know about the way its

requests are being implemented?– How can pathfinding impact behavior?

• Body configuration– Flying, landing, perching– Cornering, bunkering, peeking

• Spatial analysis– Firing position selection– Destination evaluation based on line-of-sight, range-to-

target, etc.• “Local spatial behaviors”

– Line-tracing (e.g. for diving off cliffs)– Not facing into walls– Crouch in front of each other– Don’t walk into the player’s line of fire– Curing isolation– Detecting blocked shots

• Reference frames– The viral nature of the reference frame

• Cognitive model / Object persistence– Honest perception– Simple partial awareness model

• Search– Simple by design– Group search

• Spatial conceptualization– DESIGNER-PROVIDED– Zones, Areas (areas), Firing positions (locations)

Page 7: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Problems Solved in Halo2

• Environment representation

• Object representation

• Spatial Relations

• Spatial Behaviors

Page 8: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Environment RepresentationHow do we represent the environment to the AI?

An important constraint: as few restrictions as possible on the form the geometry can take– The environment artist’s time (and artistic freedom) is precious

Page 9: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Environment RepresentationHalo2: navigation mesh constructed from the raw environment

geometry– CSG “stitching in” of static scenery

– Optimization

– “sectors”: convex, polygonal, but not planar

~10 months out of my mid-20s that I will never get back.

Page 10: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Feature ExtractionA lot of features we’re interested

in can be extracted automatically …

• Surface categorization / characterization

• Surface connectivity• Overhang detection• Interior/exterior surfaces• Ledges• Wall-bases• “Leanable” walls• Corners• “Step” sectors• Thresholds• Local environment classification

– Captures the “openness” of the environment at firing positions

Page 11: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Feature Extraction

… and a lot can’t. So we make the designers do it.

Designer “hints”:• Jumping• Climbing• Hoisting• “Wells”• Manual fix-up for when the

automatic processes fail:– Cookie-cutters

– Connectivity hints

Page 12: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Place

But that’s not enough.

The navigation graph is good for metric queries (e.g. would I run into a wall if I were to move 10 feet in this direction?)

… but not a good representation for reasoning about space

Page 13: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

PlacePsychologists talk about cognitive maps as the internal representation

of behaviorally-relevant places and how they relate.

A couple of interesting properties:• Not metric• Fuzzy• Hierarchically organized

Useful for:• Landmark navigation• Dead-reckoning• Place-learning• Self-localization

From http://www.brainconnection.com

Page 14: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

The right side of the

room

The left side of the

room

By the couch

The middle of the room

In the corner

Behind the

desk

In the cornerAlong the wall

Entry-way

PlaceIn the ideal world, we would be able to automatically

construct some kind of spatial semantic network

Page 15: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

PlaceThe Halo place representation:

A shallow hierarchy of spatial groupings:Zones Areas Positions

Page 16: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Place

Zone Organizational

Attached to a bsp

Area Defines the playground

Following

Positions Tactical analysis

Page 17: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Place

But we lose something from taking a designer-authored approach to place:

• No relational information– A LOT of work for the designers to enter

• Very little semantic information– A rudimentary example: derived “local environment

classification”: open, partially constrained or constrained

• The Designer has to do it.

Page 18: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Place

Note, in any case, the dichotomy between our cognitive map and our navigation mesh:

Navigation mesh is continuous, metric

Cognitive map is discrete, relational

??? Accuracy “Meaning” ???

Page 19: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Object Representation

How do we represent objects in a useful way to the AI?

How do psychologists think about this?• Object-based vision• Shape perception / categorization

– Contours– Axes of symmetry– Convex parts

• Reaching / grasping– Tight loop between vision and prehension– Prehension != Recognition

Page 20: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Dynamic Object Representation

Three ways to see an object:• Inherent properties• Volume• Spatial features

(This is of course in addition to the usual render, collision and physics models)

Remember Grandfather Minsky: multiple representations for the same thing, because different representations are useful for different kinds of problems

•Size•Leap-speed•Destructible•Custom behavior X

Page 21: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Volume• Rough approximation using pathfinding spheres• Spheres projected to AI’s ground-plane at pathfinding time (to

become pathfinding discs)• A perturbation of the smoothed path

Page 22: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Object FeaturesMuch like “Affordances” (Gibson, Norman, Wright)

– An object advertises the things that can be done with / to it– But they must do so in a geometrically precise way in order to be useful

Implementation: “object markers”– Rails or points– Orientation vector indicates when the affordance is active– An object has different properties at different orientations

Page 23: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Object Representation

Volume + Features = How the AI understands shape

Adding rich AI information becomes a fundamental part of the modeling of the object (just like authoring collision and physics models)

Used for• Explicit behavior

– Cornering (corner feature)– Mount-to-uncover (mount feature)– Destroy cover (destructible property)

• Pathfinding obstacle-traversal– Vault (vault feature)– Mount (mount feature)– Smash (size property)– Destroy obstacle (destructible property)

Page 24: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Relations

How do the objects in the AI’s knowledge model relate to each other spatially?

Well first of all, what’s IN the knowledge model?

In Halo2:• Potential targets (enemies)• Player(s)• Vehicles• Dead bodies• And that’s it.

Page 25: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Relations

What the KR people think…

A

D

E

B

C

A B

CDE

Covers

Contains

Below

Meet

Left

Disjoint

Left

Disjoint

From Papadias et. al Acquiring, Representing and Processing Spatial Relations, Proceedings of the 6th International Symposium on Spatial Data Handling, Edinburgh, 1994

Page 26: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Relations

Some rudimentary Halo2 examples:

• Grenade-throwing– Find clusters of nearby enemies

• Blocked shots– Recognize “I can see my target, and I wanted my bullets to go X

meters, but they only went 0.6X meters. I must be blocked.”

• Destroy-cover– Recognize that my target is behind destructible cover

• Mount-to-uncover– Recognize that my target is behind a mountable object

Page 27: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Behind the Space CrateThe notion of “behind” could happen at multiple levels

For each target, store the object, if any, that is blocking

my view of it

Make note of spatial relationship between objects

in my knowledge model (semantic network)

When I lose track of my target, perform an in-line spatial computation to determine if I should try destroying

an object in front of it.

Perception

Knowledge Model

Behavior

Halo2

Page 28: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Behind the Space CrateThe notion of “behind” could happen at multiple levels

Perception

Knowledge Model

BehaviorWhen we lose track of our target, tell perception we’re

interested in objects that are in front of it

Find the appropriate obstacle, tell the KM to

instantiate a representation for it

Store the “behind” information in a general, public (semantic net-like)

format

Page 29: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Behind the Space Crate

All of which is just to say:

• “Behind” is not an entirely trivial concept

• The collection of spatial-relation information and the management of their representation structures are not trivial either!

Page 30: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Groupings

E.g.:• Clusters of enemies• Battle fronts• Battle vectors

In Halo2: perform dynamic clumping of nearby allies, for :

• Joint behavior• Call-response combat dialogue• Shared perception

BUT, not a perceptual construct!

Page 31: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial Groupings

Cognitive Efficiency• One, two, many• Give groupings first-class

representation in the AI’s kowledge model?

• Another hierarchy– See the many as one– Or, instantiate individuals as

necessary

Page 32: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Reference Frames

What the psychologist would say:• Egocentric: viewer-relative• Allocentric: world-relative• Instrinsic: object-relative

Page 33: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Reference Frames

The most interesting use: frames of motion

E.g. AIs running around on the back of the giant scarab tank

Page 34: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Reference Frames

The hard part:• Moving sectors• Adapting A*

– A* in local space except across ref-frame boundaries

– Final path cached in local space(s)

• A new point representation:

(x,y,z,f)

Page 35: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Once we start using it one place, we have to use it everywhere!

• Sectors• Firing-positions• Scripting points• Target locations• Last-seen-location• Burst targets• Etc.

Results in a generalized “understanding” of reference frames

And like all good things AI, a lot of cool stuff falls out more or less for free.

Reference Frames

Page 36: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Spatial behavior

Two types:

• Allocentric– Generally uses the cognitive map– Typically recognized Behaviors– E.g. fight, follow, search

• Egocentric– Generally through local spatial queries– Things that should just sort of, you know, happen

Page 37: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Fighting

Position evaluation based on • Range-to-target• Line-of-sight to target• Distance from current

position• Distance to the player and

other allies• Easy!

This is the tactical spatial analysis problem.

And there are lots of published solutions out there. See in particular Van Der Sterren, Killzone’s AI: Dynamic Procedural Combat Tactics, GDC 2005

Page 38: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Following

Easy to do mediocrely

Hard and complicated to do well• Stay close• Not too close• Try and stay in front (so that player can see and appreciate) but

don’t get in the way and don’t block the player’s line of fire• What does “in front” even mean?• Don’t follow when not appropriate

In the ideal case, need player-telepathy• Look for explanation for the player’s movement, then determine

whether that explanation warrants MY adjusting my position as well.

Page 39: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

SearchThe most interesting of the spatial behaviors

As complicated as you want to get:• Fake it completely

– Play a “look around and shrug” animation• Pretend you don’t know where the player is

while exclaiming “Where’d he go?!”• Simple scripted search routines• Basic stateless hidden location-uncovering• Probabilistic location models based on spatial structure…

– Particle filters, occupancy maps– For both, negative perception is extremely important

(the places that the target is observed NOT to be at)– Both can be used for all kinds of neat things, not just search

• … based on spatial structure and spatial semantics …• … based on spatial structure and semantics and player model

The more complicated the search model, the more complicated the perception and knowledge models and the maps needed to support it.

Halo2My thesis

Page 40: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Egocentric BehaviorsThe grab-bag:• When stopped, don’t face into walls• Don’t pick a spot that blocks a friend’s line of fire• Don’t block the player’s line of fire ever• Don’t even cross the player’s line of fire.• Crouch down when someone behind me is shooting• Move with my allies, rather than treating them as obstacles• Get off non-pathfindable surfaces

These are hard, because they’re not exclusive behaviors• Things to “keep in mind”.• Which means that high-level behaviors always need to be robust to their

effects.• Suspect that we need more mid-level spatial concepts for high and low-level

behavior to interact through

Page 41: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

A Pattern Emerges…

Here is a typical course of events

1) Designer says, “we want X to happen”2) X is implemented as a behavior3) In the course of implementation, a useful representation is

invented.4) The representation, it is realized, is emminently generalizable5) The representation, and its management, is pulled out of the

behavior and made a general competence, available to all behaviors

The important point: these representations are driven by need

Page 42: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

Unsolved Mysteries

• Group movement– Queuing– Formations

• “Configuration analysis”– My relation with my allies

• Anticipation• Spatial Semantics

– Rooms and doorways– Inside / outside– Understanding more environmental

spatial features

Page 43: Dude, wheres my Warthog? From Pathfinding to General Spatial Competence Damián Isla Bungie Studios

The Grand Question(s) Redux

Is there a convergence between their explanatory models and our control models?

Our models have no respect for or interest in what is happening in the natural mind …

… but there is something satisfyingly Darwinian about the way that some useful mental representations survive while others are culled…

… and it would be thrilling if it turned out we were working on the same problem from the opposite direction.