Index of /Kuliah2016-2017/KecerdasanBuatanUntukGame

Artificial Intelligence in 
Game Design
Intelligent Motion and 
Simple Steering Behaviors

Movement in Games
• Determine desired direction of movement of 
character in some space
– Can include more complex components
• Speed
• Orientation
• Acceleration

• Meant to meet some goal






Pursuing player

Fleeing player
Moving through obstacles
Wandering/patrolling


Types of Spaces
• Usually two dimensional
– Most games involve 
“ground”
– Screen inherently 2D
• Can still use angles to appear 
3D

• 2 ½ dimensional space
– Character can move in third 
dimension in limited ways
– Jumping, etc.

Basic Game Physics
• Representation:

– Position: X, Y
– Orientation: ω

ω
X

Y

Basic Game Physics
• Velocity and rotation
– velX
– velY
– velω

velY

“speed” = sqrt(velX2 + velY2)
velω

“spin” 


• Forces to change velocity





Steering controlled by player
steerX
“acceleration”
steerY
steerω “rotational force”

velX

Basic Game Physics
Usually very small 
increments (frame rate)

• Simple update algorithm:

Update(steerX, steerY, steerω, time) {
X = X + velX * time
Y = Y + velY * time
ω = ω + velω * time

Update current 
position based on 
current velocities

velX = velX + steerX * time
velY = velY + steerY * time 
velω = velω + steerω * time
}


Update next 
velocities based on 
current steering

Note that not perfect physics, but “close enough” for fast frame rate


Limitations in Game Physics
• Only accelerate in current direction of steering (facing)
– Direction of drive wheels in car
– Direction of engines in rocket

• Single accel component 
player controls

accel
steerY
ω
steerX

– Gas pedal, etc.

• steerX = accel * cos(ω)
steerY = accel * sin(ω)

targetX ­ X


targetY ­ Y

• Will need to change ω
to achieve direction
– Target ω = atan(targetY ­ Y

targetX ­ X)

target ω

Limitations in Game Physics
• Maximums on velocity and/or steering

speed

velY

– Max speed at which character can run 
– Max gas flow/steering wheel turn in car

maxspeed

• Rotation/spin set to maximum if exceed 
– If (vel ω > maxvel ω) vel ω = maxvel ω

• Directional maximums usually for total
in both X, Y
– speed = sqrt(velX2 + velY2)