Movement for Gaming Artificial Intelligence Spring 2008.

Slides:



Advertisements
Similar presentations
Artificial Intelligence in Game Design
Advertisements

Heuristic Search techniques
7.2. AI E NGINE AND S TEERING B EHAVIOUR I Design of an AI Engine and introduction to steering in game AI.
AI Pathfinding Representing the Search Space
7.3. S TEERING B EHAVIOUR II Steering behaviours in game AI.
Pathfinding AI John See 29 Nov, 13 Dec 2010.
Torque, Equilibrium, and Stability
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Flocking and more.  NPC groups can move in cohesive groups not just independently ◦ Meadow of sheep grazing? ◦ Hunting flock of birds? ◦ Ants? Bees?
Pathfinding Basic Methods.
CSE 380 – Computer Game Programming Pathfinding AI
Projectile Motion.
Flocks, Herds, and Schools: A Distributed Behavioral Model By: Craig Reynolds Presented by: Stephanie Grosvenor.
1 CO Games Development 2 Week 22 Flocking Gareth Bellaby.
Generated Waypoint Efficiency: The efficiency considered here is defined as follows: As can be seen from the graph, for the obstruction radius values (200,
Artificial Intelligence in Game Design Intelligent Decision Making and Decision Trees.
Artificial Intelligence in Game Design Introduction to Learning.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
CS274 Spring 01 Lecture 5 Copyright © Mark Meyer Lecture V Higher Level Motion Control CS274: Computer Animation and Simulation.
Introduction What is this ? What is this ? This project is a part of a scientific research in machine learning, whose objective is to develop a system,
Circular Motion and Other Applications of Newton’s Laws
Steering Behaviors For Autonomous Characters
Projectile Motion Lecturer: Professor Stephen T. Thornton.
DAMN : A Distributed Architecture for Mobile Navigation Julio K. Rosenblatt Presented By: Chris Miles.
Games Programming III (TGP2281) – T1, 2010/2011 Movement AI John See 19, 26 Nov 2010.
Tactical AI in Real Time Supervisor: Aleks Jakulin Crew: Damir Arh, Matija Jekovec, Mitja Luštrek Gregor Leban, Martin Žnidaršič, Uroš Čibej Translation:
Unit 8 POE Ballistic Device
Neural Networks Lecture 8: Two simple learning algorithms
October 8, 2013Computer Vision Lecture 11: The Hough Transform 1 Fitting Curve Models to Edges Most contours can be well described by combining several.
MOTION.
Chapter 5.4 Artificial Intelligence: Pathfinding.
Collision and Animation Systems in Games Jani Kajala Lead Programmer / Chief Technology Officer, Pixelgene Ltd (0)
Artificial Intelligence in Game Design Problems and Goals.
Motion  1 Position, Speed and Velocity  2 Graphs of Motion  3 Acceleration.
October 14, 2014Computer Vision Lecture 11: Image Segmentation I 1Contours How should we represent contours? A good contour representation should meet.
BIPEDAL LOCOMOTION Prima Parte Antonio D'Angelo.
Study on Genetic Network Programming (GNP) with Learning and Evolution Hirasawa laboratory, Artificial Intelligence section Information architecture field.
Vectors and Direction In drawing a vector as an arrow you must choose a scale. If you walk five meters east, your displacement can be represented by a.
Department of Electrical Engineering, Southern Taiwan University Robotic Interaction Learning Lab 1 The optimization of the application of fuzzy ant colony.
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
Free fall An object undergoing free fall has an acceleration of m/s2 . This varies from the equator when it is m/s2 to the poles when it.
Kinematics in One Dimension We will focus today on problem- solving. Note: some problems are hard, some are not so hard. Part of the learning is recognizing.
One Dimensional Kinematics: Problem Solving Kinematics in Two-Dimensions: Law of Addition of Velocities Projectile Motion 8.01 W02D1.
Chapter 6 Circular Motion and Other Applications of Newton’s Laws.
Artificial Intelligence in Game Design Cooperative Movement.
Motion Planning in Games Mark Overmars Utrecht University.
Artificial Intelligence in Game Design Dynamic Path Planning Algorithms.
Jumping, Climbing, and Tactical Reasoning Section 2.5 Tom Schaible CSE 497 – AI & Game Programming.
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Toward More Realistic Pathfinding Authored by: Marco Pinter Presentation Date: 11/17/03 Presented by: Ricky Uy.
Kinematics in Two Dimensions. Section 1: Adding Vectors Graphically.
REFERENCES: FLOCKING.
Circular Motion and Other Applications of Newton’s Laws
Artificial Intelligence in Game Design Influence Maps and Decision Making.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Two Dimensional Motion Two components: Horizontal (x-axis) & Vertical (y-axis)
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
CSCE 552 Spring 2010 AI (III) By Jijun Tang. A* Pathfinding Directed search algorithm used for finding an optimal path through the game world Used knowledge.
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
MOTION. Chapter Four: Motion  4.1 Position, Speed and Velocity  4.2 Graphs of Motion  4.3 Acceleration.
CIVET seminar Presentation day: Presenter : Park, GilSoon.
Projectile Motion.
Review IMGD Engine Architecture Types Broadly, what are the two architecture types discussed for game engines? What are the differences?
CIS 488/588 Bruce R. Maxim UM-Dearborn
Fitting Curve Models to Edges
CIS 488/588 Bruce R. Maxim UM-Dearborn
Steering behaviours in game AI
CIS 488/588 Bruce R. Maxim UM-Dearborn
MOTION.
Computer Animation Displaying animation sequences raster animation
Presentation transcript:

Movement for Gaming Artificial Intelligence Spring 2008

Basics Characters in games usually move  Movement calculation often needs to interact with the “Physics” engine Avoid characters walking through each other or through obstacles  Traditional: kinematic movement Characters simply move (often at fixed speed) without regard to how physical objects accelerate or brake  Newer approach: Steering behavior or dynamic movement Characters accelerate and turn based on physics

Assumptions Game character behavior needs to be computed very fast  Often not necessary to provide sophisticated algorithms to give impression of intelligent behavior Example: Attribution of thought to Pacman’s blinky character  Character position can be modeled as a point with orientation  3-d movement is usually not necessary 2D suffices for most surface based games 2½D (3-d position and 2-d orientation) suffices for many others

Statics Character position is a point  Traditionally in gaming given as a vector in (x,z) coordinates Orientation is a 2d vector of length 1, given as  = (sin , cos  )  x z

Kinematics We describe a moving character by  Position 2-dimensional vector  Orientation 2-dimensional unit vector given by an angle, a single real value between 0 and 2   Velocity 2-dimensional vecto  Rotation 2-dimensional unit vector given by an angle, a single real value between 0 and 2 

Kinematics Update calculation  Assume frame rate is high enough  Steering is given as Steering.Linear – a 2D vector  Represents changes in velocity Steering.Angular – a real value  Represents changes in orientation  Update at each frame Position += Velocity * Time Orientation += Rotation * Time modulo (2  ) Velocity += Steering.Linear * Time Rotation += Steering.Angular * Time

Kinematic Movement Uses following static data to output a desired velocity  Position  Orientation Can lead to abrupt changes of velocity that need to be smoothed over several frames Many games simplify further and force the orientation of the character to be in the direction of the velocity

Kinematic Movement Seek algorithm  Character is given a target position  Calculate desired direction velocity = target.position – character.position  Normalize velocity to maximum velocity

Kinematic Movement Flee: Reverse the seek velocity vector Calculate desired direction velocity = character.position– target.position  Normalize velocity to maximum velocity

Kinematic Movement Seek with full velocity leads to overshooting  Arrival modification Determine arrival target radius Lower velocity within target for arrival Arrival Circle: Slow down if you get here steering.velocity = target.position – character.position; if(steering.velocity.length() < radius){ steering.velocity /= timeToTarget; if(steering.velocity.length() > MAXIMUMSPEED) steering.velocity /= steering.velocity.length(); } else steering.velocity /= steering.velocity.length();

Kinematic Movement Wandering  Always at maximum speed  Direction changes e.g. by small random changes

Dynamic Movement Steering extends kinematic movement by adding acceleration and rotation  Remember: p(t) – position at time t v(t) = p’(t) – velocity at time t a(t) = v’(t) – acceleration at time t  Hence:  p  v  v  a

Dynamic Movement Dynamic movement update  Acceleration in polar coordinates Size of acceleration (vector length) is limited  In dynamic movement model, we assume that there is a strict upper bound  In the Newtonian model, acceleration is the result of an application of force. Rotational component is also limited  Can be often disregarded

Dynamic Movement Dynamic movement update  Accelerate in direction of target until maximum velocity is reached  If target is close, lower velocity (Braking) Negative acceleration is also limited  If target is very close, stop moving Dynamic movement update with Physics engine  Acceleration is achieved by a force  Vehicles etc. suffer drag, a force opposite to velocity that increases with the size of velocity Limits velocity naturally

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: INPUT: steering data structure OUTPUT: position, orientation void Position::update(Steering& str) { this.position += this.velocity * time; // this.orientation += steering.angular * time MOD 2  ; this.orienatation = velocity.GetOrientation(); this.velocity += steering.linear*time; if(this.velocity.length()) > MAXVELOCITY) this.velocity *= MAXVELOCITY/velocity.length(); }

Dynamic Movement Seek Algorithm INPUT: target and character position OUTPUT: steering update void steering.update(Target & tar, Character & ch) { this.linear = tar.position – ch.position; if(this.linear.length() > MAXACCELERATION) this.linear *= MAXACCELERATION/this.linear.length(); }

Dynamic Movement Seek Algorithm  Seek will approach target at maximum speed  Will probably miss it by a little bit Use a target radius to stop when close enough  Need an approach algorithm Used when close to target Triggered when within approach radius of target Calculates desired speed based on time to target and distance to target

Dynamic Movement

Arrival algorithm  Define radius within which character slows 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 algorithms used do not have a target radius

INPUT: target and character position OUTPUT: steering update void Steering::update(Target & tar, Character & ch, double& radius, double& timeToTarget) { Vector2D dir = tar.position – ch.position; double distance = dir.Length(); if (distance < Epsilon) Zero(); // close enough, stop steering double targetSpeed; if (distance > radius) targetSpeed = maxSpeed; else targetSpeed = maxSpeed * distance / radius; Vector2D targetVelocity = dir*targetSpeed/distance; this.linear = targetVelocity – ch.velocity; this.linear /= timeToTarget; if(this.linear.Length()>MAXACCELERATION) this.linear /= MAXACCELERATION/linear.Length(); this.angular = 0; }

Dynamic Movement

Seeking a moving target  Current Seek / Arrive algorithm will follow a dog’s curve  More realistic behavior Calculate position of target some time in the future based on current position and velocity This fits the intelligent agent model since it used information that can be perceived

Dynamic Movement Aligning  Match orientation of character to that of another character  Careful because orientation is a value modulo 2 , so difference is misleading  Subtract character orientation from target orientation and change to be between -  and +  Character 1 orientation 0.95 radians Target orientation 0.8 radians Character 2 orientation 0.4 radians

Dynamic Movement Velocity Matching  Change velocity of character to target velocity  Check for acceleration limits

Dynamic Movement Flee  Opposite from Seek but no need to take of arriving

Dynamic Movement Delegated Behavior  Built from simpler movement components Based on target and character position  Pursue Seek, but aiming for future position of target

Dynamic Movement Delegated Behavior  Facing Makes character look at a target  Calculates target orientation  Calls align  Wandering Steering in random directions gives jerky behavior Instead:  Define a target on a (wide) circle around character or far away  Move target slowly  Call seek

Dynamic Movement Path Following  Steering behavior not towards a point, but to a path  Implemented as delegated behavior: Define (moving) target on path Use seek

Dynamic Movement Path Following Implementation I  Define (moving) target on path Find nearest point on path to character  (Already difficult) Place target ahead of nearest point on path Seek

Dynamic Movement Path Following Implementation II  Define (moving) target on path Find near-future position of character Find nearest point on path to near-future position  (Already difficult) Place target ahead of nearest point on path Seek

Dynamic Movement Path Following  These methods lead to corner cutting behavior path future position nearest point on path target on path

Dynamic Movement Path Following  Coherence problem if path crosses itself path previous point Two candidates for closest points

Dynamic Movement Separation  Common in crowd simulations where many characters head into the same direction  Identify close characters  Move away from them Linear separation: Force of separation acceleration is proportional to distance Inverse square law separation: Force of separation acceleration is inverse square of distance

Dynamic Movement Collision Avoidance  Can use variation of evade or separation behavior  Typically only include characters that are within a cone of orientation of character Collision avoidance is triggered Collision avoidance is not triggered

Dynamic Movement Collision Avoidance  Evasion behavior triggered within a cone does not work for large crowds of characters  “Panic” reaction even though collision is not imminent Algorithm ignores velocity and speed of other character Collision avoidance is triggered

Dynamic Movement Collision Avoidance  Calculate closest approach between characters  Determine whether distance at this point is less than a threshold distance before triggering evasive behavior Collision avoidance is triggered?

Dynamic Movement Collision Avoidance  Out-of-cone characters can collide

Dynamic Movement Collision Avoidance  Avoiding colliding with coordinated groups of characters Average velocity / position does not work well Instead: Calculate character in group with whom collision is most likely

Dynamic Movement Obstacle and Wall Avoidance  Simple obstacles are represented by bounding spheres  More complicated objects such as walls, houses, cliffs, etc cannot be represented by bounding spheres  Characters use a different obstacle avoidance algorithm

Dynamic Movement Obstacle and Wall Avoidance  Character casts out a single limited distance ray Collision Point

Dynamic Movement Obstacle and Wall Avoidance  Calculate Collision Point Collision Point

Dynamic Movement Obstacle and Wall Avoidance  Calculate normal of obstacle at collision point Collision Point

Dynamic Movement Obstacle and Wall Avoidance  Set target on normal at avoidance distance  Go to Seek Collision Point Target

Dynamic Movement Obstacle and Wall Avoidance  Ray casting can be very expensive  Single ray might not detect collision Use three rays instead

Dynamic Movement Obstacle and Wall Avoidance  Several configurations tried for rays Parallel side rays Central ray with short whiskers Whiskers only Single ray only

Dynamic Movement Obstacle and Wall Avoidance  Several configurations tried for rays Parallel side rays Central ray with short whiskers Whiskers only Single ray only

Dynamic Movement Obstacle and Wall Avoidance  Several configurations tried for rays Parallel side rays Central ray with short whiskers Whiskers only Single ray only

Dynamic Movement Obstacle and Wall Avoidance  Corner Trap Left ray detects collision Right ray detects no collision Whisker based algorithm sets target to the right

Dynamic Movement Obstacle and Wall Avoidance  Corner 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 Obstacle and Wall Avoidance: Corner Trap  Wide enough fan angle can avoid the problem But, wide enough fan angle does not allow characters to walk through a door Solutions:  Get level designers to make doors wide enough for AI characters  Use adaptive fan angles:  Increase fan angles if collisions are detected  Decrease fan angles if collisions are not detected  Run corner trap avoidance If character moves erratically (left/right ray detect alternatively collisions), declare one ray to be the winner

Combining Steering Behavior Blending  Execute all steering behaviors  Combine results by calculating a compromise based on weights Example: Flocking based on separation and cohesion Arbitration  Selects one proposed steering

Combining Steering Behavior Blending  Example: A group of rioting characters that need to act as a unified mob Characters need to stay by the other Characters need to keep a safe distance from each other in order not to bump into each other  For each character, calculate accelerations based on separation and cohesion For the moment, define cohesion as a force towards the projected center of the group Add both accelerations Ensure that acceleration is within potential of character, otherwise crop acceleration

Combining Steering Behavior Blending Weights  Blending weights do not need to add up to one  Blending weights can evolve Learning algorithms  Trial and Error fixed parameters

Combining Steering Behavior Flocking and Swarming  Craig Reynold’s “boids” Simulated birds Blends three steering mechanisms 1. Separation  Move away from other birds that are too close 2. Cohesion  Move to center of gravity of flock 3. Alignment  Match orientation and velocity  Equal Weights for simple flocking behavior

Combining Steering Behavior Flocking and Swarming  Separation is only calculated for very close birds  Cohesion and Alignment only consider birds within a certain neighborhood Original proposal: Define neighborhood of a boid as a cone. Boid neighborhood

Combining Steering Behavior Blending Problems  Characters can get stuck Unstable equilibrium between “seek target” and “flee enemy” steering if enemy is between character and target If enemy and target are stationary, small rounding errors usually let character flip laterally with increasing amplitude until character finally makes dash for target Enemy Target

Combining Steering Behavior Blending Problems  Characters can get stuck Stable equilibrium between “seek target” and “flee enemy” steering if enemies are between character and target Enemies Target

Combining Steering Behavior Blending Problems  Constrained Environments Tendency to return pathological behavior: Conflict between obstacle and chase Target Wall Avoidance Pursue Result

Combining Steering Behavior Blending Problems  Constrained Environments Missing a narrow doorway Collision Ray Result

Combining Steering Behavior Blending Problems  Constrained Environments Long distance failure Collision Ray

Combining Steering Behavior Blending Problems  Judder Collision Ray Obstacle Avoidance t = 1

Combining Steering Behavior Blending Problems  Judder Collision Ray No Obstacle Avoidance t = 5

Combining Steering Behavior Blending Problems  Judder Collision Ray Obstacle Avoidance t = 10

Combining Steering Behavior Blending Problems  Judder t = 15

Combining Steering Behavior Blending Problems  Judder t = 20

Combining Steering Behavior Priority Behavior  Seek or Evade will always generate an acceleration  Collision avoidance, Separation, Arrive,... will often not generate an acceleration  When blending, give priority to latter components if they propose an action Example: Seek will almost always give maximum acceleration, but if collision avoidance gives an acceleration, it should not be ignored. Weighting might limit collision avoidance to 50% influence  Can deal with stable equilibria At equilibrium, all accelerations are about balanced and total acceleration is near-zero Add a single behavior at lowest priority such as wandering

Combining Steering Behavior Priority Behavior  Can use a fixed order  Can use dynamic order Different components return also a priority value  Collision avoidance might return square inverse of distance to obstacle Select behavior based on priority value  Collision avoidance has no influence if collision is long away  But becomes hugely important just before a collision threatens

Combining Steering Behavior Uncooperative Arbitration Methods  Blending  Priorities Fixed priorities Flexible priorities Cooperative Arbitration Methods  Use more complex decision making processes

Physics Based Trajectory Prediction 3D-movement Most common example:  Shooting or throwing objects Characters should be able to shoot or throw accurately Often, characters should be able to avoid incoming fire

Physics Based Trajectory Prediction Projectile Trajectory  Absent air resistance, follows a parabola  p – position at time t  u – firing position (normalized vector)  g – force of gravity  s m – muzzle speed

Physics Based Trajectory Prediction Predicting a landing spot  Calculate height (solve for y-component) No solution: Projectile never reaches that height One solution: Projectile reaches height at its vertex Two solutions: Pick greater value  Greater value is for projectile descending.  If this value is negative, projectile has already passed the height and will not reach it again  Obtain x-z positions of this point Note: When a character wants to catch a ball, height should be at chest

Physics Based Trajectory Prediction Firing solution  Consists of muzzle speed Usually limited to one (guns) or a few values  And firing direction Set d vector from start to end point Find times when height is zero Select long or short time trajectory Calculate firing trajectory

Physics Based Trajectory Prediction Projectiles with Drag  Physical reality is quite complex Drag gives a second order non-linear differential equations Rotation (such as a spinning golf ball) can create a lift Wind Create a simplified Physics (a.k.a. cheat) or use a numeric solution for trajetory calculation  Calculate trajectory in simplified model  Adjust firing solution to create a new trajectory that fits better

Jumping Shooter games need jumping Jumping is not part of steering mechanisms Jumps can be failures  Character tries to jump from one platform to another but fails  Cost of error larger than for steering Slight errors when pursuing are corrected

Jumping Character must set up for jump on the right, but not on the left:

Jumping Character uses velocity matching steering mechanism to make the jump:  Character decides to take the jump Pathfinding decides that character needs to jump,  this gives also type of jump OR Simple steering mechanism drives character over edge,  this needs look ahead to determine type of jump  New steering behavior to do velocity matching to do jump  When character reaches jump point, new jump action is required

Jumping Jumps are difficult to make  if good landing area is small Create jump points for characters in level design  Player characters can try to make difficult jumps, but AI characters cannot  Minimize number of occasions where this limitation becomes obvious Level design needs to hide weaknesses in the AI

Jumping Alternative uses pairs of jump points and landing pads  When character decides to make the jump, add additional step: Use trajectory prediction code to calculate velocity required to reach landing area  This allows characters to take their own physics (weight, load, strength) into account Use velocity matching steering algorithm

Jumping Hole Fillers  Create an invisible jumpable gap as part of certain obstacles  Change obstacle avoidance behavior: When detecting collision with a jumpable gap, character runs towards gap at full speed. Just before the gap, character leaps into air Works well if landing area is large Fails for small landing areas  In this case, ensure that level design does not have small landing areas. jumpable gap object Chasm

Coordinated Movement Done by groups of characters Coordinated movement  can result from individual decisions  can result from decisions made by group as a whole

Coordinated Movement Fixed formations  Usually with a designated leader  Leader moves as an individual, everybody else moves based on leaders position  Actual position depends on number of characters Line V or Finger Four Defensive circle Two abreast in cover

Coordinated Movement Emergent Formations  Each character has its own steering system Arrive Behavior  Characters select their target based on other characters in group Allows characters to avoid obstacles individually Difficult to get rules that do not lead to pathological formations

Coordinated Movement Two-Level Formation Steering  Have pseudo-character that serves as formation leader: anchor point  Individual characters steer individually Use arrival, avoidance, and separation behavior to reach target slot  Has difficulties when characters run into obstacles and cannot keep up with group

Coordinated Movement Two-Level Formation Steering Prevent problems for characters keeping up by  Slow the formation down (about half of character speed)  Moderate movement of formation based on current positions of characters in slot Reset kinematics of anchor point  Base position, orientation, velocity of anchor points on the average of characters in the slot  Choosing exactly the average means that characters are almost in position, so that they move slowly towards their slot position.  Anchor point moves even slower  etc.  Move anchor point ahead of the average for moving formations  Set anchor point to average for stationary formations  Ensure that anchor point orientation is average orientation of slots, or formation will spin around

Coordinated Movement Extension of coordination to more than two levels  Needed for military simulation games with lots of units Consult public military manuals how to organize a platoon in different squads  Slot positions now distinguish between roles of characters: E.g. Fire teams, squad leader, communication, platoon leader, heavy weapons team, …

Coordinated Movement Dynamic slots and playbooks  Not all games can use constant formations  Slots can be dynamic E.g. Fielders in a textbook baseball double play E.g. Corner kick strategies in soccer

Coordinated Movement Tactical Movement  Squads in dangerous terrain collaborate with other squads One squad moves Other squad(s) provide lookout and fire cover

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 movement request components to suppress impossible ones Divide component in lateral and forward component Filter out much of lateral component Movement request Filter out much of lateral component

Motor Control Output Filtering  Filter movement request components to suppress impossible ones  Resulting acceleration can be very small In our example, this does not look to bad, because car needs to start moving slowly Resulting Acceleration

Motor Control Output Filtering  Occasionally leads to desirable behavior Example: J-turn  Police car backs up and then rushes forward after the speeding German tourists Pursuing Car Target

Motor Control Output Filtering  Can be pathological Example: Filtering leads to zero acceleration.  Tourists speed away Pursuing Car Target movement request

Motor Control Output filtering  Tends to work unless: small margin of error in steering requests  Driving at high speed  Maneuvering through tight spaces  Matching motion to jumping  Filtering problems such as zero acceleration can be solved by heuristics “Speed forward”

Motor Control Capability sensitive steering  AI now takes capabilities of characters into account E.g.: Pursuing character chooses among a set of feasible maneuvers Tends to work if there are few alternatives

Motor Control Capability sensitive steering  AI now takes capabilities of characters into account skidding car Target

Motor Control Capability sensitive steering  Avoidance algorithm creates unrealistic steering skidding car Target

Motor Control Capability sensitive steering  Creates more realistic solution Car accelerates to avoid obstacle skidding car Target

Motor Control Capability-sensitive steering  Is difficult when several steering behaviors need to be combined  Best practice: Leave actuation to the last step

Motor Control Common actuation properties:  Humans Can turn fast at low speed Can sidestep or turn on the spot if stationary or slowly moving  Cars and Motorbikes Cannot turn while stationary Turning radius more extended with increased speed Can brake faster than accelerate when traveling in a straight line Cannot travel quickly backward (motorbikes not at all)  Tracked vehicles Can completely turn at low speeds Turning capabilities limited by grip at high speeds.

Pathfinding for Gaming Artificial Intelligence

Graph Generation For many situations, approximating a layout with a graph is sufficient

A* Heuristics A good heuristics is crucial for performance Optimal path results from a heuristics that always under-estimates the actual path length The closer a heuristics is to true distance, the faster the algorithm performs Sometimes performance is more importance than optimality:  Pick a good heuristics that sometimes under- estimates distance and gives a non-optimal path

A* Heuristics Euclidean distance can be misleading

A* Heuristics Cluster Heuristics  Agglomerate related vertices into clusters B C F G H

A* Heuristics Cluster Heuristics  Distance within cluster is estimated to zero  Distances between clusters is in a look-up table B C F G H ABCDEFGHI A0 B09225 C D0 E0 F22069 G28602 H5 920 I0

World Representation Pathfinding uses a reduction of game level to a graph  Graph can be designed by level designer, Dirichlet Domains  By automatic tools, Tile graphs Points of visibility Polygonal meshes  Or by augmenting tools with manual supervision Criteria for world representation  Validity Paths need to be doable  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 Dirichlet Domains a.k.a. Voronoi polygon  Given a finite set of source points, a Dirichlet domain is the set of all points closest to a given source point  Metric might be non- standard  Connections are placed between neighboring domains

World Representation Dirichlet Domain  Often specified by artist for level design because automatic generation is slow  Pathfinding solution might not be feasible Traveling to two adjacent Dirichlet domains might in actuality lead through a third domain that is impassable In practice, seems to work very well  Pathfinding itself is fast

World Representation Points of Visibility  Place nodes (aka waypoints) at important locations Such as the center points of Dirichlet domains  Form graph from these nodes: Place edges whenever two nodes can see each other Precompute optimal travel between waypoints Or rerun algorithm on waypoint graph  Simple navigation from A to B Move to nearest waypoint to A. Move along path between waypoints Move from nearest waypoint to B to B itself  Can use path smoothing to make walk look more realistic

World Representation A B optimal path Points of Visibility  Optimal paths in 2D run along inflection points Inflection points are those where path curves  Inflection points located at convex corners of obstacles  Create nodes there  Move them away for characters with thickness

World Representation Polygonal Meshes  Created by level designer as a mesh

World Representation Non-translation  Nodes do not have to reflect position but can embody more information Example: Slow moving ship  Nodes reflect position and direction  Pathfinding find a way for the ship to be in the correct position and be correctly oriented

Hierarchical Pathfinding Higher level of hierarchy has nodes that represent a cluster of nodes of the lower hierarchy

Hierarchical Pathfinding Connection costs at higher level  At the lowest level: Depends on where you leave and enter a given node group  Minimum Distance between two nodes in group A and B  Maximin Distance: Determine the minimum distance for each node in A to B Then return the maximum  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 distance Tends to visit to many higher level nodes  Maximin distance Tends to go for the most direct path at the higher level

Continuous Time Pathfinding Pathfinding has difficulties with dynamic scenarios  Police car chasing a suspect on an LA freeway Path now has a time component Create nodes that abstract both time and location  Leads to very dense, populated graphs

Movement Planning Animations  Modeling the character as a point can look bad Going up stairs Stepping over stepping stones

Movement Planning Animations  Create different velocity ranges based on current position of character running walking creeping turning sidestepping

Movement Planning Create Planning Graph  Nodes incorporate different location and different stances  Edges represent various transitions “Get up” Walk Run

Movement Planning Footfalls  Determine where character will plant feet