Game Development Reference
In-Depth Information
'
'
go to the AI roundtables at the Game Developer
m continually
intrigued by the dichotomy between experienced video game AI developers and
developers coming from academia or other fields of AI. Academics tend to want to
create as intelligent an agent as possible, whereas game developers often just want the
player to have fun. Game AI is not about trying to make something smart; it
s Conference, I
s about
making something look smart while still being able to be beaten, though not too eas-
ily. That
'
s what makes the game fun, and the key to game AI is fun through illusion,
not true intelligence. If you have a military shooter game, who cares whether or not
the enemies really work together as a team as long as the player believes they do? As
AI programmers, we
'
re the ultimate illusionists. And we have to do it all within a
tiny fraction of CPU time.
'
AI Techniques
AI programming is one part science and two parts art. I
ve spent most of my career
working on AI for games. Most of the time in AI development is spent trying to bal-
ance everything elegantly so it all behaves in a cohesive fashion. For example, at what
point does a sim get hungry? When should sims start looking for food? What if they
really have to go to the bathroom, or they
'
re about to pass out? Should food take
priority, and if so, how hungry does a sim have to be before it will get food and
risk passing out? RPGs, shooters, strategy games, and any other game with a signifi-
cant AI presence will need to balance factors appropriate to that title.
AI often works best when you can exploit emergent behavior. In the Sims example,
there are a number of competing systems all weighing against each other to make the
final decision. There
'
sno if statement saying that if hunger is less than 20, start
finding food. Instead, the sim weighs its desire for food against its desire for every-
thing else and chooses an action based on all of these things. This gives us the emer-
gent behavior of sim prioritizing food over other things. In the game F.E.A.R., it often
appears that the soldiers are working together, but there is absolutely no code to do
this directly. It ' s mostly just the clever use of assets and the emergent behavior of the
group from the combined behaviors of the individuals. We
'
'
ll talk more about these
concepts later in this chapter.
Hard-Coded AI
In the early days of game programming, AI was often completely hard coded. Let
s
look at a trivial example: that of a light timer. Suppose you want to build a vacation
timer for your lights so that they come on at a specified time and turn off at another
time. The implementation might look something like this:
'
 
 
 
Search WWH ::




Custom Search