Sony Computer Entertainment

Slides:



Advertisements
Similar presentations
Lecture 7: Potential Fields and Model Predictive Control
Advertisements

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.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Flocking and more.  NPC groups can move in cohesive groups not just independently ◦ Meadow of sheep grazing? ◦ Hunting flock of birds? ◦ Ants? Bees?
Steering Behaviors GAM 376 Robin Burke Winter 2008.
CSE 380 – Computer Game Programming Pathfinding AI
Flocks, Herds, and Schools: A Distributed Behavioral Model By: Craig Reynolds Presented by: Stephanie Grosvenor.
Optimizing Flocking Controllers using Gradient Descent
Florian Klein Flocking Cooperation with Limited Communication in Mobile Networks.
Kristen Gardner. Outline Swarm Intelligence Flocking Basic Steering Swarms Applications Animals Vehicles People.
Flocking References: xxx.
The Vector Field Histogram Erick Tryzelaar November 14, 2001 Robotic Motion Planning A Method Developed by J. Borenstein and Y. Koren.
Continuous Collision Detection: Progress and Challenges Gino van den Bergen dtecta
Human-Computer Interaction Human-Computer Interaction Segmentation Hanyang University Jong-Il Park.
Image Segmentation and Active Contour
1Notes  Assignment 2 is out  Flocking references  Reynolds, “Flocks, Herds, and Schools…”, SIGGRAPH’87  Tu and Terzopoulos, “Artificial Fishes…”, SIGGRAPH’94.
Particle Systems 1 Adapted from: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012.
Lesson 5 Representing Fields Geometrically. Class 13 Today, we will: review characteristics of field lines and contours learn more about electric field.
Shape Modeling International 2007 – University of Utah, School of Computing Robust Smooth Feature Extraction from Point Clouds Joel Daniels ¹ Linh Ha ¹.
Continuum Crowds Adrien Treuille, Siggraph 王上文.
CS274 Spring 01 Lecture 5 Copyright © Mark Meyer Lecture V Higher Level Motion Control CS274: Computer Animation and Simulation.
1cs426-winter-2008 Notes  Please read: C. Reynolds “Flocks, Herds, and Schools…” SIGGRAPH ‘87
Steering Behaviors For Autonomous Characters
Games Programming III (TGP2281) – T1, 2010/2011 Movement AI John See 19, 26 Nov 2010.
1Notes. 2 Time integration for particles  Back to the ODE problem, either  Accuracy, stability, and ease-of- implementation are main issues  Obviously.
Gravity and Orbits The gravitational force between two objects:
Chapter 5.4 Artificial Intelligence: Pathfinding.
Introduction Tracking the corners Camera model and collision detection Keyframes Path Correction Controlling the entire path of a virtual camera In computer.
Localisation & Navigation
Flow Fields Hao Li and Howard Hamilton. Motivation for Flow Fields Multiple AI algorithms in a computer game can produce conflicting results. The AI must.
Steering Autonomous Characters Spring 2005 Ref: Craig Reynolds.
Artificial Intelligence for Games Lecture 1 1 Minor Games Programming.
1 Game AI Steering Behavior & Group Movement ( 轉向行為 及 群體運動 )
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Basic Steering of Game Agents Featuring Guest professors Stephen Sheneman & Michael Wilkens 1.
Demonstration Design Light Sensor Truck Light As the truck passes the light, the light sensor turns off the power to the truck, ensuring that the truck.
REFERENCES: FLOCKING.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
Beard & McLain, “Small Unmanned Aircraft,” Princeton University Press, 2012, Chapter 12: Slide 1 Chapter 12 Path Planning.
Fundamentals of Computer Animation Controlling Groups of Objects (2)
Review IMGD Engine Architecture Types Broadly, what are the two architecture types discussed for game engines? What are the differences?
Animating Human Locomotion
Conductors and Gauss’s Law
Chapter 12 Driving in Adverse Conditions
A Little Capacitance and Current and Resistance
PHYS 1444 – Section 501 Lecture #16
PHYS 1444 – Section 004 Lecture #11
CS1371 Introduction to Computing for Engineers
Algorithm Analysis CSE 2011 Winter September 2018.
Gauss’s Law Electric Flux
Data Mining (and machine learning)
Speed & Velocity.
Driving in City Traffic
Steering Behaviors GAM 376 Robin Burke Fall 2006.
Navigation In Dynamic Environment
Motion Planning for Multiple Autonomous Vehicles
8.1. Steering Behaviour III
CIS 488/588 Bruce R. Maxim UM-Dearborn
Steering behaviours in game AI
Where did we stop? The Bayes decision rule guarantees an optimal classification… … But it requires the knowledge of P(ci|x) (or p(x|ci) and P(ci)) We.
Physics 11a.
Using the “Clicker” If you have a clicker now, and did not do this last time, please enter your ID in your clicker. First, turn on your clicker by sliding.
Thermal Energy & Heat Capacity:
Computer Animation Algorithms and Techniques
Filtering Images Work in the spatial domain
CO Games Concepts Week 12 Collision Detection
Presentation transcript:

Sony Computer Entertainment Steering Behaviours Robin Green Sony Computer Entertainment Robin_Green@playstation.sony.com

Definitions Vehicle Behaviour The abstract representation of a moving object. Behaviour Code that generates a steering force each iteration.

The Vehicle Object

The Vehicle Object A vehicle is represented in this tutorial by a circle in 2D space or sphere in 3D. Diagrams will use triangles or circles (with correct extent) with velocity vector.

The Vehicle Object A vehicle must have: Optional extras: position velocity radius set of behaviours maximum force maximum velocity Optional extras: mass orientation local reference frame target references formation position

A Basic Vehicle class Vehicle { public: void update(); public: BehaviourList list; float mass; Vector2d pos; Vector2d vel; float max_force; float max_speed; };

Integration Euler Integration Not accurate, not elegant but fast.

Clamping Forces Clamp the vector length of forces to max_force and max_speed.

Updating The Vehicle The ratio of max_force to max_speed will control 1. Time it takes to get to max_speed 2. Turning circle radius (rate of change of direction) 3. Stopping speed (rate of change of speed) 4. Accuracy of hitting targets

Updating The Vehicle void Vehicle::update() { Vector2d force(0,0); BehaviourList::iterator i; for(int i=list.begin(); i!=list.end(); ++i) { force += i->calculate(); } Vector2d steering = truncate(force,max_force); Vector2d acc = steering / mass; vel += truncate(vel + acc, max_speed); pos += vel; }

Behaviours

Behaviours Seek & Flee Pursue & Evade Arrival Offset Pursuit Formations Obstacle Avoidance Separation Follow Path Avoid Walls Wander Follow Flow Field Interpose & Hide Collision Avoidance Flocking

Designing Behaviours Generate a desired velocity Calculate from the current state where the vehicle should be going. Calculate the steering force Calculate the difference between current and desired velocities: steering = desired - vel;

Seek & Flee Seek Flee vel pos target desired = normalise(target-pos) * max_speed; steering = desired - vel; steering steering desired = normalise(pos-target) * max_speed; steering = desired - vel;

Pursue & Evade Predict target position Seek that position Maybe using distance to target and time to turn. Seek that position predicted predict = target.pos + time * target.vel; desired steering steering desired = normalise(predict - pos) * max_speed; steering = desired - vel;

Arrival How fast do we need to go to get to the target in decel_time units of time? steering dist = length(target-pos); speed = min(distance/decel_time, max_speed); desired = normalise(target-pos) * speed; steering = desired - vel; desired max_speed <max_speed

Offset Pursuit Move through a point adjacent to a target Find target in local space. Convert target to world space. Seek target position.

Formation Seek a position defined by a Leader’s local-space formation. Find target in Leader’s local space. Convert target to world space. Seek target position.

Wander Causes vehicles to follow a smoothed random path. In local space, construct a circle in front of the vehicle. Pick a target point on the circle. Add a random vector to the target position, then reproject the target onto the circle. Project the target into world space. Seek the target point.

Separation Force vehicles to use space more realistically. Search world for neighbours within a search radius. For each neighbour, calculate and accumulate a 1.0/distance2 repelling force. Truncate resulting vector to max_force

Avoid Obstacle Keep a box in front of the vehicle free of obstacles. Search world for collision candidates. Project their positions into local space. In local space, choose closest obstacle to steer away from. Generate lateral steering force. Project steering force back into world space.

Avoid Obstacle Tweaks In addition: Scale length of box w.r.t. velocity (anticipating obstacles). Scale repelling force w.r.t. distance from vehicle (steering more to avoid close obstacles). Add small negative amount of velocity proportional to distance from vehicle (vehicle brakes to steer).

Follow Path Three strategies for path following: 1. Dog On A String 2. Reprojections 3. Grappling Hooks.

Parts Of A Path A path is a polyline of “waypoints”. Each line between waypoints is a “path segment”. A collection of path segments is a “subpath” subpath destination waypoint current

Dog On A String Linearly interpolate a target point down the polyline. Measure distance from vehicle to target to calculate the target increment. Seek the target point.

Reprojection Calculate the vehicle’s position in the near future. Project that future position onto the path. Use “closest point on line to point” calculation. Seek that projected position. In effect keeping the vehicle within a wide stroke path.

Grappling Hook Starting with the first waypoint, keep a note of the “current waypoint”. Seek the current waypoint. If distance to current < threshold, increment current. NOTE: Only works on line-of-sight paths.

Avoid Walls Predict the vehicle’s future position. If future pos intersects a wall Reproject the future position onto the wall surface along the surface normal. Extend this reprojection vector. Seek the target point. Else return no steering vector.

Follow Flow Field Predict your vehicle’s position forward in time. Look up the desired velocity from the flow field map. You may like to bilinear filter the value from surrounding samples for smoothness. steering = flow_field[x,y] - vel;

Interpose & Hide Interpose Hide Seek a target halfway along the vector between two objects. Hide Pick a point inside the occluding object. Seek a target extended beyond that point.

Unaligned Collision Avoidance One of the more complicated behaviours. Picture two groups of vehicles passing through each other at a crossroads, each vehicle avoiding collisions. Three parts to this behaviour: 1. Neighbour search. 2. Find Closest Approach. 3. Take Evasive Action

Unaligned Collision Avoidance 1. Neighbour Search. Important to set an upper bound on the search area. Vehicles probably won’t be travelling in a straight line for too long. Search returns a set of “collision candidates” for further tests Ideal search area (assuming constant velocity) Approximated search area.

Unaligned Collision Avoidance 2. Find closest approach Find the one candidate that will collide soonest assuming constant velocity. p v p v p = B.pos - A.pos v = B.vel - A.vel a = v.p b = v.v time = - a / b dist_sq = p.p + 2*a*time + b*time*time p |v| = 0 p v

Unaligned Collision Avoidance 3. Take Evasive Action Vehicles can speed-up/brake and they can turn to avoid. How to choose? Avoiding Strategy: If one vehicle has extra velocity, speed up. If vehicles both are at max_speed, choose one to brake and turn. If distance > threshold, both vehicles turn. etc... Steering to avoid collision

Flocking 1. Separation 2. Cohesion 3. Alignment The “Boids” flocking algorithm is comprised of three concurrent behaviours: 1. Separation 2. Cohesion 3. Alignment

Separation Covered earlier. The 1/r2 repelling force isn’t intrinsic and can be replaced with a different scaled force for interesting effects.

Cohesion Vehicles in the same area tent towards the mean point. This forces vehicles on the outside to bind together into flocks rather than fly off independently. For each vehicle, search for neighbours, calc. the mean position and seek that point.

Alignment Vehicles in the same area tend to face the same direction. This forces flocks to swirl as direction changes propogate through the flock. For each vehicle, search for neighbours, calc. the mean facing direction, add in correcting force.

Combining Behaviours

Types of Behaviour Constant Forces Occasional Forces Behaviours that produce a force every iteration e.g. Follow Path, Follow Flow Field, Wander Occasional Forces Behaviours that produce forces occasionally e.g. Separation, Avoid Walls, Avoid Obstacle

Ordering Behaviours Often, behaviours should be ordered in importance. The ordering used in DK2 was: 1. Vehicles MUST NOT intersect walls. 2. Vehicles SHOULD NOT intersect obstacles. 3. Vehicles should TRY NOT to intersect each other. How to code this as an expression?

Weighted Average Take the force vectors from N behaviours, scale them and sum the result. void Vehicle::next_step() { Vector2d steering(0,0); BehaviourList::iterator i; for(i = behaviour_list.begin(); i != behaviour_list.end(); ++i) { steering += i->calculate_force(*this) * i->behaviour_scale; } … }

Weighted Average Problems It’s expensive. Calculate every behaviour for every vehicle each iteration. When to truncate to max_speed? Truncation needed to allow important forces to swamp unimportant ones. Scaling forces leads to undesirable effects. Scaling path motion forces forces means vehicles movea long paths more slowly than you thought. How big should the scaling be? Do scale factors sum to 1.0? How big does a force need to be to swamp all other forces? Trial and Error.

Prioritised Dithering Generate a random value X. If X < some threshold, execute the first behaviour. Else execute one of the remaining behaviours until a non-zero force is returned.

Prioritised Dithering void Vehicle::calc_steering() { Vector2d steering(0,0); if(random() < 0.65f) steering = containment(this); if(steering.is_zero()) steering = avoid_obstacle(this); if(steering.is_zero()) steering = follow_path(this); … }

Prioritised Dithering Problems Continuous Behaviours MUST be randomised. If they’re not randomised, they will block lower behaviours by always returning a value. How to design the ordering is unclear. Which behaviours need to be executed first? What thresholds are needed to ensure they get priority? Trial and error.

Gotchas

Extent Problems Path Finding doesn’t take extent into account Paths intersect corners and along the edges of walls. Behaviours had to be robust enough to handle these cases.

Extent Problems Density of objects on the map was often unrealistic. Large creatures couldn’t fit between large obstacles but still had to move realistically. Careful attention paid to cancelling out and truncating forces correctly.

Extent Problems Large obstacles were missed in neighbourhood searches. Vehicles seemed to suddenly “remember” that they were intersecting a large obstacle. Return neighbours based on the cells they intersect, not just the cell they are created in.

Changing World Problems Creating obstacles dynamically can trap small vehicles. Corner columns in rooms would trap imps who were re-enforcing walls. Vehicles had an “escape stuck mode” to enforce several iterations of ignoring obstacles.

AI Controls for Path Following The AI has additional information on why a vehicle is going to a target. Vehicle needs to run an animation when it arrives Vehicle is going to be redirected when it arrives (pass through a target point) Vehicle is going to interact with an obstacle. Additional information is needed to help path following meet these goals.

AI Controls for Path Following Extra flags were used: Arrive With Velocity - use seek for final waypoint. Arrive And Stop - use arrive for final waypoint. Ignore Final Obstacles - don’t use repel_obstacle for final. Repel Final Obstacles - use repel_obstacle for final seg. Ignore Final Creatures - don’t use separation for final seg. Repel Final Creatures - use separation for final path seg. Accurate Positioning - linearly interpolate along final segment. Loose Positioning - use arrive + threshold for final seg.

The End