Professional Documents
Culture Documents
Gaming
Artificial Intelligence
Spring 2008
Basics
Traditional:
kinematic movement
Newer
Assumptions
Character
orientation
3-d movement is usually not necessary
Statics
Kinematics
2-dimensional vector
Orientation
Velocity
2-dimensional vecto
Rotation
Kinematics
Update calculation
Steering.Linear a 2D vector
Kinematic Movement
Kinematic Movement
Seek algorithm
Character
Normalize
Kinematic Movement
Normalize
Kinematic Movement
modification
Arrival Circle:
Slow down if
you get here
Kinematic Movement
Wandering
Always
at maximum speed
Direction changes
Dynamic Movement
Hence:
p v
v a
Dynamic Movement
in polar coordinates
Dynamic Movement
is reached
If target is close, lower velocity (Braking)
If
is achieved by a force
Vehicles etc. suffer drag, a force opposite to velocity
that increases with the size of velocity
Dynamic Movement
Position Update:
class Position
{
protected: Vector2D position;
Vector2D velocity[2];
double orientation, rotation;
friend class Steering;
public: ...
}
Dynamic Movement
Position Update:
class Steering
{
private:
Vector2D linear; // Acceleration Vector
double angular; // describes changes in orientation
public:
...
}
Dynamic Movement
Position Update:
Dynamic Movement
Seek Algorithm
Dynamic Movement
Seek Algorithm
Seek
Need
an approach algorithm
Dynamic Movement
Dynamic Movement
Arrival algorithm
Define
down
Calculate optimal speed to target
If current speed is slower, accelerate towards
target
If current speed is faster, accelerate away from the
target
Many
Dynamic Movement
Dynamic Movement
Dynamic Movement
Aligning
Match
Target
Character 1
orientation 0.95 radians
Character 2
orientation 0.4 radians
Dynamic Movement
Velocity Matching
Change
Dynamic Movement
Flee
Opposite
arriving
Dynamic Movement
Delegated Behavior
Built
from simpler
movement components
Pursue
Dynamic Movement
Delegated Behavior
Facing
Wandering
Dynamic Movement
Path Following
Steering
path
Implemented as delegated behavior:
Define (moving) target on path
Use seek
Dynamic Movement
(Already difficult)
Dynamic Movement
(Already difficult)
Dynamic Movement
Path Following
These
path
Dynamic Movement
Path Following
Coherence
previous
point
path
Dynamic Movement
Separation
Common
Dynamic Movement
Collision Avoidance
Can
Dynamic Movement
Collision Avoidance
Evasion
Collision avoidance is
triggered
Dynamic Movement
Collision Avoidance
Calculate
Collision avoidance is
triggered?
Dynamic Movement
Collision Avoidance
Out-of-cone
Dynamic Movement
Collision Avoidance
Avoiding
Dynamic Movement
Dynamic Movement
ray
Collision Point
Dynamic Movement
Collision Point
Collision Point
Dynamic Movement
Dynamic Movement
Target
Dynamic Movement
Dynamic Movement
Dynamic Movement
Dynamic Movement
Dynamic Movement
Trap
Dynamic Movement
Trap
Algorithm steers character straight towards
the corner
Now right ray detects collision
Left ray detects no collision
Algorithm sets target to the
right
Dynamic Movement
But, wide enough fan angle does not allow characters to walk
through a door
Solutions:
Run
Blending
Execute
Arbitration
Selects
Blending
Example:
For
Blending Weights
Blending
one
Blending weights can evolve
Learning algorithms
Trial
Simulated birds
Blends three steering mechanisms
1.
2.
3.
Separation
Move away from other birds that are too close
Cohesion
Move to center of gravity of flock
Alignment
Match orientation and velocity
Boid neighborhood
Blending Problems
Characters
Enemy
Target
Blending Problems
Characters
Enemies Target
Blending Problems
Constrained
Environments
Result
Pursue
Wall Avoidance
Target
Blending Problems
Constrained
Environments
Result
Collision Ray
Blending Problems
Constrained
Environments
Collision Ray
Blending Problems
Judder
Obstacle
Avoidance
Collision Ray
t=1
Blending Problems
Judder
No Obstacle
Avoidance
Collision Ray
t=5
Blending Problems
Judder
Obstacle
Avoidance
Collision Ray
t = 10
Blending Problems
Judder
t = 15
Blending Problems
Judder
t = 20
Priority Behavior
Priority Behavior
Can
Fixed priorities
Flexible priorities
Shooting
or throwing objects
Projectile Trajectory
Absent
t
p(t ) p(0) smut g
2
p
position at time t
u firing position (normalized vector)
g force of gravity
sm muzzle speed
Obtain
Firing solution
timpact 2
g d sm (g d s m ) 2 g d
2
2g
2
2d gtimpact
2 smtimpact
Jumping
Shooter games need jumping
Jumping is not part of steering
mechanisms
Jumps can be failures
Character
Jumping
Jumping
OR
Simple steering mechanism drives character over edge,
Jumping
Jumping
Jumping
Hole Fillers
When detecting collision with a jumpable gap, character runs towards gap at
full speed.
Just before the gap, character leaps into air
In this case, ensure that level design does not have small landing areas.
Chasm
jumpable gap object
Coordinated Movement
Done by groups of characters
Coordinated movement
can
Coordinated Movement
Fixed formations
Usually
Line
Defensive circle
V or Finger
Four
Two abreast
in cover
Coordinated Movement
Emergent Formations
Each
Arrive Behavior
Characters
Coordinated Movement
Has
Coordinated Movement
Coordinated Movement
Slot
Coordinated Movement
Coordinated Movement
Tactical Movement
Squads
Motor Control
Interpret output from steering behavior as
movement requests
Character (such as a car) might not be
able to satisfy this request by laws of
physics
Movement
request
Motor Control
Output Filtering
Filter
Motor Control
Output Filtering
Filter
Motor Control
Output Filtering
Occasionally
Example: J-turn
Pursuing
Car
Target
Motor Control
Output Filtering
Can
be pathological
Target
Motor Control
Output filtering
Tends
to work unless:
Filtering
Speed forward
Motor Control
Motor Control
Target
Motor Control
steering
skidding
car
Target
Motor Control
Target
skidding
car
Motor Control
Capability-sensitive steering
Is
Motor Control
Cars
and Motorbikes
Tracked
vehicles
Pathfinding for
Gaming
Artificial Intelligence
Graph Generation
A* Heuristics
a good heuristics that sometimes underestimates distance and gives a non-optimal path
A* Heuristics
A* Heuristics
Cluster Heuristics
Agglomerate
F
B
A* Heuristics
15
within cluster
is estimated to zero
Distances between
clusters is in a look-up
table
H
15
G
B
Distance
Cluster Heuristics
World Representation
By automatic tools,
Dirichlet Domains
Tile graphs
Points of visibility
Polygonal meshes
Validity
Usefulness
Real Time Strategy (RTS) game with hundreds of thousands of tiles cannot
use them for pathfinding
Pathfinding results might appear blocky and irregular
World Representation
World Representation
Dirichlet Domain
Often
Pathfinding
itself is fast
World Representation
Points of Visibility
World Representation
Points of Visibility
Optimal
paths in 2D run
along inflection points
Inflection
points located at
convex corners of
obstacles
Create nodes there
Move them away for
characters with thickness
optimal path
World Representation
Polygonal Meshes
Created
World Representation
Non-translation
Nodes
Hierarchical Pathfinding
Hierarchical Pathfinding
Minimum
B
Maximin Distance:
Average
Minimum Distance
Hierarchical Pathfinding
Strange Effects:
Circuitous
Paths
High Level Plan
Hierarchical Pathfinding
Strange Effects:
Circuitous
Paths
Better Plan Missed
Hierarchical Pathfinding
Strange Effects
Minimum
Maximin
distance
distance
Leads
Movement Planning
Animations
Modeling
bad
Going up stairs
Stepping over stepping stones
Movement Planning
Animations
Create
Movement Planning
Movement Planning
Footfalls
Determine