Steering behaviours in game AI

Slides:



Advertisements
Similar presentations
Rotation, Angular Momentum and Gravity
Advertisements

7.2. AI E NGINE AND S TEERING B EHAVIOUR I Design of an AI Engine and introduction to steering in game AI.
7.1. O SCARS & A RTIFICIAL I NTELLIGENCE Interim awards and introduction to game AI.
7.3. S TEERING B EHAVIOUR II Steering behaviours in game AI.
Flocking and more.  NPC groups can move in cohesive groups not just independently ◦ Meadow of sheep grazing? ◦ Hunting flock of birds? ◦ Ants? Bees?
Projectile Motion with Wind and Air Resistance
CSE 380 – Computer Game Programming Pathfinding AI
Flocking References: xxx.
Rotation and Torque Lecture 09 Thursday: 12 February 2004.
Presenter: Robin van Olst. Prof. Dr. Dirk Helbing Heads two divisions of the German Physical Society of the ETH Zurich Ph.D. Péter Molnár Associate Professor.
Chapter 8: Rotational Kinematics Lecture Notes
3D orientation.
Angular Motion. Measuring a Circle  We use degrees to measure position around the circle.  There are 2  radians in the circle. This matches 360°This.
CS274 Spring 01 Lecture 5 Copyright © Mark Meyer Lecture V Higher Level Motion Control CS274: Computer Animation and Simulation.
Steering Behaviors For Autonomous Characters
Rotation of a Rigid Body (Chapter 10)
Games Programming III (TGP2281) – T1, 2010/2011 Movement AI John See 19, 26 Nov 2010.
Angular Variables. Measuring a Circle  We use degrees to measure position around the circle.  There are 2  radians in the circle. This matches 360°This.
Rotational Motion. Rotational motion is the motion of a body about an internal axis. In rotational motion the axis of motion is part of the moving object.
Movement for Gaming Artificial Intelligence Spring 2008.
CS Reinforcement Learning1 Reinforcement Learning Variation on Supervised Learning Exact target outputs are not given Some variation of reward is.
Indoor Localization Using a Modern Smartphone Carick Wienke Advisor: Dr. Nicholas Kirsch Although indoor localization is an important tool for a wide range.
Rotation Rotational Variables Angular Vectors Linear and Angular Variables Rotational Kinetic Energy Rotational Inertia Parallel Axis Theorem Newton’s.
College Physics, 7th Edition
Rotational Motion Comparison of Angular Motion with One-dimensional Horizontal Motion Distance traveled is replaced by the angle traveled around the circle.
Chapter 8: Rotational Kinematics Essential Concepts and Summary.
Chapter 8 Rotational Kinematics. Radians Angular Displacement  Angle through which something is rotated  Counterclockwise => positive(+) Units => radians.
Artificial Intelligence in Game Design Cooperative Movement.
motiontranslationaverage speed Rotation kinematics center of mass Center of gravity gravitational force Gravity displacement direction Vector quantity.
Angular Kinematics of Human Movement
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Chasing, Evading, Intercepting, Pattern Movements
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
Basic Steering of Game Agents Featuring Guest professors Stephen Sheneman & Michael Wilkens 1.
REFERENCES: FLOCKING.
Course14 Dynamic Vision. Biological vision can cope with changing world Moving and changing objects Change illumination Change View-point.
Section 6-2 Linear and Angular Velocity. Angular displacement – As any circular object rotates counterclockwise about its center, an object at the edge.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
Circular Motion. Rotational Quantities A O r  dAdA A point on an object, located a distance r from a fixed axis of rotation, rotates in such a way that.
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
Demonstration of Simple Movement using Python AI for Gaming 2013, SCU.
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
行動 (Movement) 靜宜大學資工系 蔡奇偉 副教授.
Chapter 10 - Rotational Kinematics
Angular Kinematics of Human Movement
Kinetics of Particles: Newton’s Second Law
Types of cams.
Introduction & Rectilinear Kinematics:
Circular Motion How do we work out the velocity of something which is moving at constant speed in a circle ? Answer: We use the simple formula: But in.
Circular Motion.
Sony Computer Entertainment
Projectile Motion AP Physics C.
Rotation As you come in, please set clicker to channel 44 and then answer the following question (before the lecture starts). Quiz – You are building.
Steering Behaviors GAM 376 Robin Burke Fall 2006.
Angular Kinematics of Human Movement
MEE 214 (Dynamics) Tuesday
Last Time: Vectors Introduction to Two-Dimensional Motion Today:
PHYS 211 Exam 1 HKN Review Session
8.1. Steering Behaviour III
CIS 488/588 Bruce R. Maxim UM-Dearborn
Basic Biomechanics, (5th edition) by Susan J. Hall, Ph.D.
9.1. Board Games and Aiming AI
Kinematics Vectors and Motion
Uniform Circular Motion Review
Section 2 –Linear and Angular Velocity
A projectile launched at an angle
Rotational Motion Let’s begin with Rotational Kinematics!!
Rotational Kinematics
Presentation transcript:

Steering behaviours in game AI 7.3. Steering Behaviour II Steering behaviours in game AI

Question Clinic: FAQ In lecture exploration of answers to frequently asked student questions

Steering Movement Algorithms Execution Management Movement Strategy Decision Making World Interface Animation Physics ... Steering Movement Algorithms Forms of dynamic (or steering) movement algorithm

Seek Seek will try to match the source position of that to a target location. As with the kinematic seek the direction to the target is determined, and a corresponding maximum acceleration set towards the target. Initial velocity Target acceleration Path Seek ( Vector source, Vector target, float maxAcc ) { Vector acceleration = (target – source).normalise() * maxAcc; return acceleration; } Aside: Seek will accelerate as fast as possible towards the target. Evidently some means of dampening/reducing velocity will be needed as the target is approached – this is offered by other forms of steering behaviour.

Seek Flee The output of Seek is used to update the position and velocity as follows: Flee is simply the opposite of Seek, with a maximum acceleration away from the target output. UpdatePosition() { velocity += acceleration * timeDelta; rotation += angular_acc * timeDelta; if( velocity.length() > maxSpeed ) velocity = velocity.normalise()*maxSpeed; position += velocity * timeDelta; orientation += rotation * timeDelta; } timeDelta amount of time since last update Seek Flee Aside: The Seek algorithm does not change the orientation, i.e. other forms of steering algorithm can be used to align orientation with direction of movement.

Arrive Arrive will control acceleration so that the velocity is zero once the target has been reached. To do this, two radii are used: an arrival radius when the target can be considered as reached, and a larger slow radius used to control when the velocity should be reduced from the maximum. Seek Arrive Aside: The opposite to Arrive is Leave – although there is little need to have a behaviour that will slowly accelerate away from the target. It is more likely to have a behaviour that accelerates away with maximum acceleration, i.e. Flee.

Arrive float targetSpeed; if( distance > slowRadius ) If outside slow radius, then max speed, else scale speed based on distance float targetSpeed; if( distance > slowRadius ) targetSpeed = maxSpeed; else targetSpeed = maxSpeed * distance / slowRadius; Vector targetVelocity = direction.normalise() * targetSpeed; Arrive Arrive(Vector source, Vector target, Vector currentVelocity, float maxAcceleration, float maxSpeed, float arriveRadius, float slowRadius ) { float slowingFactor = 0.2; Vector acceleration = [0,0,.]; Vector direction = target – source; float distance = direction.length(); if( distance < arriveRadius ) return acceleration; { Determine target velocity } { Determine acceleration } return acceleration } slowingFactor = deaccelerate strength Calc acceleration so that it will slow down object near target acceleration = targetVelocity – currentVelocity; acceleration /= slowingFactor; if( acceleration.length() > maxAcceleration ) acceleration = acceleration.normalise() * maxAcceleration; return 0 if at target

Wander Wander will produce a movement that gives the impression of a random walk. In order to avoid jittery behaviour a circle can be projected in front of the object with steering towards a target that is constrained to move along the perimeter. Each update, the target is displaced by a small random amount (moving back and forth around the perimeter over time). By controlling size of circle, distance from object and random displacement, a wide range of motion can be generated. Wander target Circle at a defined fixed distance from object Wander output

Wander Wander( Vector source, float sourceOrientation, float maxAcceleration, float wanderOffset, float wanderRadius, float wanderRate, float wanderOrientation ) { wanderOrientation += wanderRate * randomBinomial(); targetOrientation = wanderOrientation + sourceOrientation; Vector target = source + wanderOffset * asVector(sourceOrientation); target += wanderRadius * asVector(targetOrientation) {Return acceleration based on a Seek towards the determine target location } wanderOrientation wanderOffset wanderRadius wanderRate source Work out new target orientation Any random function will suffice, binomial is smooth Work out new target position Return a (2D) vector with the same orientation as the specified angle Vector2 asVector( float angle ) { return new Vector2( (float)Math.Cos(angle), (float)Math.Sin(angle) ); }

Pursuit Seek will head directly towards the target. If the target is moving, it is better to aim towards where the target is likely to be in the future – a behaviour known as Pursuit. Different algorithms can be used to predict the likely future position. A simple, yet effective, approach is to assume the target will continue to move with the same current velocity. The target’s movement can then be used to calculate it’s future position, which is used as the seek position. Seek route Pursue route Target velocity

Pursuit Evade Pursuit( Vector source, Vector target, Vector sourceVel, Vector targetVel ) { float maxPrediction; Vector direction = target – source; float distance = direction.length(); float speed = sourceVel.length(); If( speed <= distance / maxPrediction ) prediction = maxPrediction; else prediction = distance / speed; target += targetVel * prediction; return Seek( source, target) } Evade is simply the opposite of Pursuit, i.e. the evaders flees from the projected future direction Maximum future time in which to predict Predicted future position Calculated Seek target If time to target is too long, then use maximum prediction time, else determine time to contact Target velocity Determine new target location and return Seek acceleration towards it Time to contact = distance / speed

Interpose Interpose steers towards the mid point of two defined targets (e.g. for intercepting a pass, blocking a shot, etc.). It is similar to Pursuit except that a mid-point between the targets is calculated, and the time to this point used to determine the future locations of the targets. The predicted future locations are then used to find the target mid- point for the Seek behaviour. Current mid-point Predicted mid-point Predicted future position

Align Align tries to match the orientation of the source with that of the target (i.e. there is no linear movement, only rotation). Align is very similar to Arrive with one added aspect: orientations wrap around every 2π radians, entailing some range mapping. Align uses two ranged triggers: one for reducing the angular velocity, and another when the alignment is close enough. Map the input angle into the [-π, π] range float standardiseAngle( float input ) { float output = input % (2π); if( Math.abs(output) > π) output += Math.signum(output) * 2π; }

Align float targetRotation = 0.0; if( rotationSize > slowAngle ) targetRotation = maxRotation; else targetRotation = maxRotation * rotationSize / slowRadius targetRotation *= signum( rotation ); Align source orientation and target orientation Align(float source, float target, float maxAngularAcc, float maxRotation, float arriveAngle, float slowAngle ) { float slowingFactor = 0.2; float angularAcceleration = 0.0; float rotation = standardiseAngle( target – source); float rotationSize = abs(rotation); if( rotationSize < arriveAngle ) return angularAcceleration ; { Determine target rotation } { Determine angular acceleration } return angularAcceleration } If outside slow distance then max rotation, else slow rotation depending on difference Reintroduce rotation direction (left/right) Determine difference in orientation angularAcceleration = targetRotation – source; angularAcceleration /= slowingFactor If( abs(angularAcceleration ) > maxAngularAcc ) angularAcceleration /= angularAcceleration * maxAngularAcc; Same structure as for Arrive

Face Face steers the source to look at the target. To do this, a target orientation towards the target is calculated and then Align used to provide the steering acceleration. Face( Vector source, Vector target ) { Vector direction = target – source; if( direction.length() > 0 ) Align( ...direction ... );

LookWhereYouAreGoing This form of steering can be used to orientate the character to the direction of movement. The process is nearly identical to Face, except that the target direction is based on the current velocity. LookWhereYouAreGoing( Vector velocity ) { if( velocity.length() > 0 ) { float direction = atan2(-velocity.x, velocity.z); Align( ... direction ... ); }

Summary Today we explored: A number of dynamic steering algorithms – providing building blocks of more complex movement algorithms To do: If applicable to your game, test and explore movement algorithms. Finish your planning for what you hope to do for the Alpha handin