Professional Documents
Culture Documents
GAME AI ENGINE
Design of a game Artificial Intelligence Engine
In simple games, AI
tends to be bespoke and
individually written for
each character (e.g.
embedded within the
layer/object update
method).
Execution
Execution
Management
Management
W
W
or
or
ld
ld
In
In
te
te
rfrf
aa
cc
ee
Higher-level AI applies
to groups, whilst lowerlevel AI operates on
individual game
objects.
te
SSt tr raa t e
ggyy
u
( (GGr rooI )u
pp AA I )
DDeecci si si o
io
nn
MMaakki n
i ngg
( (CChhaar r
AAI )I )
Animati
Animati
on
on
MMoovveem
meenn
tt
((CChhaarraacctt
eerr AAI I))
Physics
Physics
...
...
W
oW
ro
lr
dl
d
The movement
component contains a
range of algorithms
that make decisions
about motion.
I
nI
tn
et
re
fr
af
ca
ec
e
AI Engine (movement)
Execution
Execution
Management
Management
SSt t
r ar a
t et eM o
o
ggy yvM
e
ve
mmee
nnt
t
Ani
Ani Phy ...
mati
Phy
mati sics
...
on
sics
on
I
nI
tn
et
re
fr
af
ca
ec
e
Selected behaviours
are then translated
into action (possibly
making use of
movement AI, or
simply triggering an
animation).
Execution
Execution
Management
Management
SSt t
r ar a
t et eM o
o
ggy yvM
e
ve
mmee
nnt
t
Ani
Ani Phy ...
mati
Phy
mati sics
...
on
sics
on
In other words,
strategic AI controls/
influences the
behaviour of a group
of characters, often
devolving the
execution of the
group behaviour to
individual decision
making / movement
algorithms.
W
oW
ro
lr
dl
d
AI Engine (strategy)
I
nI
tn
et
re
fr
af
ca
ec
e
In order to coordinate
the behaviour of
multiple game
objects some form of
strategic AI is often
needed.
Execution
Execution
Management
Management
SSt t
r ar a
t et eM o
o
ggy yvM
e
ve
mmee
nnt
t
Ani
Ani Phy ...
mati
Phy
mati sics
...
on
sics
on
Execution
ExecutionManagement
Management
SSt rt ar at t
eeggy y
W
W
orl
orl
d
d
Int
Int
erf
erf
ac
ac
e
e
MMov
o vem
em
en
t
ent
Animation
Animation
Physics
Physics
...
...
INTRODUCTION TO MOVEMENT
Introduction to the different forms of movement AI
Introduction to movement AI
Introduction to movement
AI
Steering algorithms
output
an acceleration (or force)
(kinematics)
In
some game types a
movement algorithm can
directly update the
position/orientation (e.g.
tile-based). However, this
will look unrealistic in
other types of game (e.g.
driving).
In order to permit
continuous (2D)
movement it is necessary
Vector
position
tofloat
store:
orientation;
Vector
velocity;
float rotation;
applied to directional or
rotational velocities. Using
the Newton Euler
equations, the variables
can be updated as follows:
velocity += acceleration * time_delta
rotation += angular_acc * time_delta
position += velocity * time_delta
orientation += rotation * time_delta
Aside: In most 3D games,
characters are usually under
the influence of gravity, with
movement effectively
KINEMATIC MOVEMENT
ALGORITHMS
Basic forms of kinematic movement algorithm
Based upon
Artificial Intelligence for Games
Kinematic movement
algorithms operate using
positions and orientations. The
output is a target velocity
(speed + orientation).
To do:
r if
Conside
le
applicab
Seek
Target velocity
DetermineOrientation(
Vector velocity, float currentOrientation ) {
vector
vector of
of unit
unit length
length
and
and same
same direction
direction
if( velocity.length() == 0 )
return currentOrientation;
else
return Math.atan2( -velocity.x,
velocity.y)
Vector velocity
= (target source).normalise()
* maxSpeed;
return velocity;
}
Current velocity
See
See common
common on
on next
next slide
slide for
for atan
atan
Flee
}
This is useful to find the
direction from one point to
Arrive
slowingFactor
slowingFactor ==
slowing
slowing strength
strength
Closeness
threshold
return velocity;
vel = max
Determine
Determine velocity,
velocity, and
and
cap
cap at
at max
max speed
speed ifif
needed
needed
STEERING MOVEMENT
ALGORITHMS
Forms of dynamic (or steering) movement algorithm
Based upon
Artificial Intelligence for Games
To do:
r if
Conside
le
applicab
Seek path
To do:
Th i n k
ab o u t
nt
moveme
Summary
Today we
explored:
The design of
an AI engine
Kinematic
forms of
movement AI
Introduction to
steering forms
of movement
AI
To do:
ion
t
s
e
u
Q
e
t
le
p
Com
Clinic
e
m
a
g
r
u
o
y
e
n
fi
Iterate/re
I
A
e
n
fi
e
d
o
t
n
desig
n e ed s
at
h
w
n
la
p
o
t
e
Continu
or the
f
o
d
o
t
e
p
o
h
you
Alpha handin