+ All Categories
Home > Documents > basicmove_cis15466

basicmove_cis15466

Date post: 19-Jan-2016
Category:
Upload: wolfang-salazar-mora
View: 6 times
Download: 0 times
Share this document with a friend
Popular Tags:
40
15-466 Computer Game Programming Movement: Basic Movement Maxim Likhachev Robotics Institute Carnegie Mellon University
Transcript
Page 1: basicmove_cis15466

15-466

Computer Game Programming

Movement: Basic Movement

Maxim Likhachev

Robotics Institute

Carnegie Mellon University

Page 2: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 2

Overall Movement Hierarchy

Page 3: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 3

Overall Movement Hierarchy

based on the state of the

game decides action and

computes a path

computes the desired

direction of the motion at

every frame

computes the actual

direction of the motion at

every frame

simulates the motion and

updates the position/velocity

of the character

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 4: basicmove_cis15466

Maxim Likhachev

computes the actual

direction of the motion at

every frame

Carnegie Mellon University 4

Overall Movement Hierarchy

based on the state of the

game decides action and

computes a path

computes the desired

direction of the motion at

every frame

simulates the motion and

updates the position/velocity

of the character

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 5: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 5

Overall Movement Hierarchy

decide on action

compute path

compute motion

velocity

simulate motion

and update

position/velocity

state of the game

Page 6: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 6

Overall Movement Hierarchy

decide on action

compute path

compute motion

velocity

simulate motion

and update

position/velocity

state of the game

compute motion

direction

compute motion

velocity

=

Page 7: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 7

Definition of the System

compute motion

direction

compute motion

velocity

• Coordinate system for position P=[x,z] or P=[x,y,z]

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 8: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 8

Definition of the System

compute motion

direction

compute motion

velocity

• Coordinate system for orientation Ψ (in rads)

orientation is where it

looks (not necessarily

where it goes)

character is reduced to

a point

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 9: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 9

Definition of the System

compute motion

direction

compute motion

velocity

State of system:position P = [x,z]

• Kinematic movement

Page 10: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 10

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:velocity V = [Vx,Vy] =[magnitude v, direction θ],

orientation Ψ

• Kinematic movement

Page 11: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 11

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:velocity V = [Vx,Vy] =[magnitude v, direction θ],

orientation Ψ

• Kinematic movement

What Ψ should be set to?

Page 12: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 12

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:velocity V = [Vx,Vy] =[magnitude v, direction θ],

orientation Ψ

• Kinematic movement

Any problems with this

approach?

Page 13: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 13

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:velocity V = [Vx,Vy] =[magnitude v, direction θ],

orientation Ψ

• Kinematic movement

Any solutions?

Page 14: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 14

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:velocity V = [Vx,Vy] =[magnitude v, direction θ],

orientation Ψ

• Kinematic movement

instantaneous changes to

orientation & velocity can

be smoothed out here by

interpolation

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 15: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 15

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:velocity V = [Vx,Vy] =[magnitude v, direction θ],

orientation Ψ

• Kinematic movement

Output of the overall system: V, Ψ

Page 16: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 16

Definition of the System

compute motion

direction

compute motion

velocity

State of system:position P = [x,z],

velocity V = [Vx,Vy] =[magnitude v, direction θ],

orientation Ψ

angular speed dΨ

• Dynamic movement

Page 17: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 17

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:acceleration A = [Ax,Az],

angular acceleration ddΨ

• Dynamic movement

Page 18: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 18

Definition of the System

compute motion

direction

compute motion

velocity

Output of system:acceleration A = [Ax,Az],

angular acceleration ddΨ

• Dynamic movement

Output of the overall system: V, Ψ

Also limit V, dΨ to

their max values

Page 19: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 19

Position Update According to Motion Equation

• Continuous formulation for constant acceleration:

simulate motion

and update

position/velocity

atvtv

vtvat

dtdt

dvadt

dt

dva

t t

0

0

0 0

)(

)(

2

00

0

2

0

0

0

0

0 0

2

1)(

)(2

1

)()(

attvPtP

PtPattv

PtPdtatv

dtdt

dPvdt

dt

dPv

t

t t

compute motion

velocity

Page 20: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 20

Position Update According to Motion Equation

• Continuous formulation for constant acceleration:

simulate motion

and update

position/velocity

2

00

0

2

0

0

0

0

0 0

2

1)(

)(2

1

)()(

attvPtP

PtPattv

PtPdtatv

dtdt

dPvdt

dt

dPv

t

t tsame derivation for

orientation Ψ and angular

speed dΨ

compute motion

velocityatvtv

vtvat

dtdt

dvadt

dt

dva

t t

0

0

0 0

)(

)(

Page 21: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 21

Position Update According to Motion Equation

• Discrete formulation:

V[t+1] = V[t] + A[t]∆t

P[t+1] = P[t] + V[t]∆t + 0.5A[t]∆t2

dΨ[t+1] = dΨ[t] + ddΨ[t]∆t

Ψ[t+1] = Ψ[t] + dΨ[t]∆t + 0.5ddΨ[t]∆t2

simulate motion

and update

position/velocity

compute motion

velocity

Units for ∆t?

Page 22: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 22

Position Update According to Motion Equation

• Discrete formulation simplified:

V[t+1] = V[t] + A[t]∆t

P[t+1] = P[t] + V[t]∆t

dΨ[t+1] = dΨ[t] + ddΨ[t]∆t

Ψ[t+1] = Ψ[t] + dΨ[t]∆t

simulate motion

and update

position/velocity

compute motion

velocity

Why can we do it?

Page 23: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 23

Kinematic Seek Behavior

• Move towards a target point T

V=[v, θ]= [max. speed,λ]

Ψ=λ

P

T

compute motion

direction

λ

How do we do flee?

Page 24: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 24

Kinematic Flee Behavior

• Move away from a target point T

V=[v, θ]= [max. speed,λ+π]

Ψ=λ+π

P

T

compute motion

direction

λ

Page 25: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 25

Kinematic Seek Behavior

• Move towards a target point T

V=[v, θ]= [max. speed,λ]

Ψ=λ

P

T

compute motion

direction

λ

Problems approaching a

moving target?

Solutions?

Page 26: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 26

Kinematic Arrival Behavior

• Approach a target point T

if d < arrival radius

V=[v, θ]= [0,λ]

Ψ=λ

else

V=[v, θ]= [K*d,λ] for some constant K

Ψ=λ

P

T

compute motion

direction

λ

d

Familiar to control

folks?

Page 27: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 27

Kinematic Wander Behavior

• Random wandering

dΨ = random with bias towards 0

Ψ= Ψ+dΨ

V=[v, θ]= [max. speed,Ψ]

compute motion

direction

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 28: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 28

Dynamic Seek Behavior

• Move towards a target point T

A=max. accel *normalize([dx,dz])

ddΨ=K(Ψ-λ) limited by max. angular acceleration

P

T

compute motion

direction

λ

ddz

dx

Take care for angle

wrapping

Page 29: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 29

Dynamic Seek Behavior

• Move towards a target point T

A=max. accel *normalize([dx,dz])

ddΨ=K(Ψ-λ) limited by max. angular acceleration

P

T

compute motion

direction

λ

How do we do flee?

ddz

dx

Take care for angle

wrapping

Page 30: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 30

Dynamic Flee Behavior

• Move away from a target point T

A=-max. accel *normalize([dx,dz])

ddΨ=K(Ψ-λ-π) limited by max. angular acceleration

compute motion

direction

P

T

λ

ddz

dx

Page 31: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 31

Dynamic Flee Behavior

• Move away from a target point T

A=-max. accel *normalize([dx,dz])

ddΨ=K(Ψ-λ-π) limited by max. angular acceleration

compute motion

direction

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 32: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 32

Dynamic Flee Behavior

• Move away from a target point T

A=-max. accel *normalize([dx,dz])

ddΨ=K(Ψ-λ-π) limited by max. angular acceleration

compute motion

direction

http://www.red3d.com/cwr/steer/SeekFlee.html

Page 33: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 33

Dynamic Arrive Behavior

• Approach a target point T

if d < arrival radius then vdes=0

else vdes=K*d for some constant K

A=K1*(vdes-vcurrent)*normalize([dx,dz])

ddΨ=K(Ψ-λ-π) limited by max. angular acceleration

compute motion

direction

K1 can be set to 1/T

(T is in secs)

Meaning of T?

P

T

λ

ddz

dx

Page 34: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 34

Dynamic Arrive Behavior

• Approach a target point T

if d < arrival radius then vdes=0

else vdes=K*d for some constant K

A=K1*(vdes-vcurrent)*normalize([dx,dz])

ddΨ=K(Ψ-λ-π) limited by max. angular acceleration

compute motion

direction

from “Artificial Intelligence for Games” by I. Millington & J. Funge

Page 35: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 35

Dynamic Arrive Behavior

• Approach a target point T

if d < arrival radius then vdes=0

else vdes=K*d for some constant K

A=K1*(vdes-vcurrent)*normalize([dx,dz])

ddΨ=K(Ψ-λ-π) limited by max. angular acceleration

compute motion

direction

http://www.red3d.com/cwr/steer/Arrival.html

Page 36: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 36

Dynamic Arrive Behavior

• Approach a target point T

if d < arrival radius then vdes=0

else vdes=K*d for some constant K

A=K1*(vdes-vcurrent)*normalize([dx,dz])

ddΨ=K(Ψ-λ-π) limited by max. angular acceleration

compute motion

direction

How would you

implement

velocity matching

behavior?

Page 37: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 37

Dynamic Pursue Behavior

• Pursue a moving target T that isn’t closecompute motion

direction

P

T

λ

ddz

dx

T T … T

Where will seek

direct the

character?What’s the

problem? Solutions?

Page 38: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 38

Dynamic Pursue Behavior

• Pursue a moving target T that isn’t close

seek with target position at:

d/vcurrent*VT

compute motion

direction

P

T

λ

ddz

dx

T T … T

Where will pursue

direct the

character?

Page 39: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 39

Dynamic Evade Behavior

• Evade a moving target T that isn’t close

flee with target position at:

d/vcurrent*VT

compute motion

direction

P

T

λ

ddz

dx

T T … T

Page 40: basicmove_cis15466

Maxim Likhachev Carnegie Mellon University 40

Dynamic Evade Behavior

• Evade a moving target T that isn’t close

flee with target position at:

d/vcurrent*VT

compute motion

direction

http://www.red3d.com/cwr/steer/PursueEvade.html