ARTIFICIAL INTELLIGENCE Motion Lecturer: Silja Renooij These slides - - PowerPoint PPT Presentation

artificial intelligence motion
SMART_READER_LITE
LIVE PREVIEW

ARTIFICIAL INTELLIGENCE Motion Lecturer: Silja Renooij These slides - - PowerPoint PPT Presentation

Utrecht University INFOB2KI 2019-2020 The Netherlands ARTIFICIAL INTELLIGENCE Motion Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html Outline Move in 2D


slide-1
SLIDE 1

ARTIFICIAL INTELLIGENCE

Lecturer: Silja Renooij

Motion

Utrecht University The Netherlands

These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html

INFOB2KI 2019-2020

slide-2
SLIDE 2

Outline

  • Move in 2D
  • Individual steering behaviors

– Seek, flee, wander – Obstacle avoidance – Jumping

  • Move in 3D
slide-3
SLIDE 3

Motion: the action of changing location or position Kinematics:

  • branch of classical mechanics
  • describes motion of points, (systems of) bodies

((groups of) objects)

  • without consideration of the causes of motion

(forces, energies).

Motion & Kinematics

slide-4
SLIDE 4

Kinematic quantities:

  • Position

– 2D / 3D vector

  • Orientation

– (=‘facing’) radians

  • Velocity

– (= speed in direction) 2D / 3D vector

  • Rotation

– (= change in orientation) radians

In simulation/game: updated each frame

Kinematics

slide-5
SLIDE 5

Seek, Flee and Arrive behaviours

character: target: + (can be moving as well)

slide-6
SLIDE 6

Kinematic Seek

character #kinematic data character target #kinematic data target maxSpeed #maximum speed of character def getSteering(): steering = new KinematicSteeringOutput() steering.velocity = target.position – character.position # direction of target steering.velocity.normalize() steering.velocity *= maxSpeed # full speed in direction character.orientation = getNewOrientation(character.orientation,steering.velocity) # face in direct. of move steering.rotation = 0 return steering

Computations are done in each frame!

slide-7
SLIDE 7

Kinematic Arrive

character #kinematic data character target #kinematic data target input Seek maxSpeed #maximum speed of character radius #satisfaction radius (‘found’ target) timeToTarget = 0.25 #goal: get to target in 0.25s input Arrive def getSteering(): steering = new KinematicSteeringOutput() steering.velocity = target.position – character.position if steering.velocity.length() < radius: return None #arrived! steering.velocity /= timeToTarget #speed=distance/time if steering.velocity.length() > maxSpeed: #unless above max steering.velocity.normalize() steering.velocity *= maxSpeed character.orientation = getNewOrientation(character.orientation,steering.velocity) steering.rotation = 0 return steering

slide-8
SLIDE 8

Kinematic Wandering

Simple implementation:

  • move with max speed in direction of randomly

chosen orientation  erratic behavior

  • behaviour resembles seeking target in a random

spot on a circle surrounding the character: This analogy allows for simple improvements:

slide-9
SLIDE 9

Kinematic movement

  • Input: static kinematic data (position,orientation);

 output velocity and rotation

  • Velocity: speed `on’ or `off’ in target direction
  • Orientation usually in travelling direction; otherwise

rotation can be applied

Steering behavior

  • Extends kinematic movement by adding changes to

velocity and rotation

  • Input: kinematics; output: linear and angular acceleration
  • Variable matching: typically one or more characters’

kinematic matched to target kinematic

Kinematic movement vs Steering

slide-10
SLIDE 10

Character # kinematic data character target # kinematic data target input Seek maxAcceleration # maximum acceleration maxSpeed # maximum speed of character targetRadius # satisfaction radius input Arrive slowRadius # radius to slow down timeToTarget = 0.1 # 0.1s to achieve target velocity def getSteering(target): steering = new SteeringOutput() direction = target.position – character.position distance = direction.length() if distance < targetRadius: return None # arrived! if distance > slowRadius: targetSpeed = maxSpeed # move with maxspeed else targetSpeed = maxSpeed * distance / slowRadius # slow down if close targetVelocity = direction targetVelocity.normalize() targetVelocity *= targetSpeed steering.linear = target.position – character.position # only for Seek; remove for Arrive steering.linear = target.velocity – character.velocity # accelerate to target velocity steering.linear /=timeToTarget if steering.linear.length() > maxAcceleration: steering.linear.normalize() steering.linear *= maxAcceleration steering.angular = 0 return steering

Seek & Arrive with acceleration

slide-11
SLIDE 11

Align - Orientation

Similar to Arrive with accel.:

direction, velocity  rotation position  orientation distance  rotationSize steering.linear  steering.angular

slide-12
SLIDE 12

Align - Velocity

Character # kinematic data character target # kinematic data target maxAcceleration # maximum acceleration maxSpeed # maximum speed of character maxRotation # maximum rotation targetRadius # satisfaction radius slowRadius # radius to slow down timeToTarget = 0.1

# 0.1s to achieve target velocity

def getSteering(target): steering = new SteeringOutput() steering.linear = target.velocity – character.velocity steering.linear /=timeToTarget if steering.linear.length() > maxAcceleration: steeringlinear.normalize() steering.linear *= maxAcceleration steering.angular = 0 return steering

= Arrive with acceleration stripped down to velocity matching… Useful in combination with

  • ther behaviours in e.g.

flocking.

slide-13
SLIDE 13
  • Pursue

– predict target’s position, then seek

More complex behaviors

slide-14
SLIDE 14

(vanilla) path following:

  • Find nearest point N on path
  • Target T = point on path at N + fixed offset
  • Seek T

Multiple options?

  • Often choose for coherence

(new target close to old one) The whole path is a target and should be followed.

Follow path: vanilla

slide-15
SLIDE 15

Follow path: predictive

Predictive path following:

  • Find nearest point N on path,

from predicted future position

  • Proceed as with vanilla pathfinding
  • Smoother for complex tasks
  • Drawback (?): cutting corners

The whole path is a target and should be followed.

slide-16
SLIDE 16

Repulsion or separation

character targets threshold # threshold to take action decayCoefficient # constant for decay maxAcceleration def getSteering(): steering = new Steering for target in targets: direction = target.position – character.position distance = direction.length() target is too close if distance < threshold: strength = min(decayCoefficient / (distance ^2), maxAcceleration) #repulsion strength direction.normalize() steering.linear += strength * direction add acceleration return steering

Context: keeps characters from getting too close and being crowded

slide-17
SLIDE 17

Concerns collisions with moving targets Simple:

  • Variation of evade/separate;

– engaged if target is within cone in front of character

  • Drawback: in-cone doesn’t have to mean collision

and vice versa

Collision avoidance

slide-18
SLIDE 18

Concerns collisions with moving targets Better:

  • Find target closest to collision
  • For each target

– Find out if collide (moment of collision) – If collide, find out when and where – Steer away from that target

Collision avoidance

slide-19
SLIDE 19
  • Use casting rays to find obstacles
  • Multi-ray problem: “corner trap”

Single ray Multiple rays Multiple rays

Obstacle avoidance

One ray Two whiskers

Often used solution

slide-20
SLIDE 20

Obstacle avoidance

State of the art

slide-21
SLIDE 21

Combining steering

e.g. flocking, swarming,…

Weighted blending

– Combine steering behavior by computing the weighted sum of all blended behaviors – Problem: equilibria and worse

– Alternatives: prioritize; cooperative arbitration; …

target Seek target avoid enemy 1 avoid enemy 2 enemy 2 enemy 1 Wall avoidance result pursue

trapped (do nothing) lost target

slide-22
SLIDE 22

Jumping

  • Jump might fail! (unlike steering)
  • Where to jump?

– Jump pads in level – Jumpable holes (design like walls; jump instead of avoid)

  • How to jump?

– Need speed, direction and place to start

  • When to jump?

– Often determined by path finding

slide-23
SLIDE 23

Moving in 3 dimensions

More than just one more degree of freedom:

  • Gravity
  • Height of obstacles
  • Stairways
  • Lines of sight
  • Capabilities (jump, fly, …)
slide-24
SLIDE 24

Moving in 3 dimensions