Game Development Reference
nearby neighbors. Not only are these behaviors simple, they do not involve the
entire flock—just the local group. Because one of the behaviors avoids crowding,
it provides a limit to the complexity of the computations required for a single
boid, regardless of how high the total number of boids goes .
This computationally cheap algorithm produces lifelike results. The motion is
often described as organic or realistic , even when simulated birds are drawn with
simple triangles that look more like paper airplanes. Two similar but not iden-
tical flocks flying the same route will usually behave visibly—but not wildly—
differently. It can be maddening to attempt this level of realism with other AI
methods, particularly those with a centralized control mechanism.
While the life-like results are computationally cheap, so are any undesired
behaviors. Emergent behavior can be hard to predict, difficult to tune, hard to
control, and generally frustrating. The simplicity of the methods can be stymied
by complex situations, something demonstrated to anyone who has seen a
simple-minded bird trying to escape from the inside of a complex building.
This chapter is devoted to giving our software agents lifelike interactions. While
the easiest way to do this is to copy the state of the art, we will examine what goes
on under the hood in modest depth. We will use a freeway-simulation project,
Cars and Trucks , as an example to illustrate some of the real-world issues that
arise. Thankfully, this kind of AI is conceptually simple and rather robust. It even
applies to behaviors outside of steering.
In various versions of the Frankenstein story, Dr. Frankenstein pounds his fist or
exhorts to the thundering skies, ''Give my creature life!'' It does not turn out
quite like he planned, however. Indeed, in some versions, it appears not to
happen at all—at least not at first.
Anyone can make boids flock, but game developers are in the business of creating
new and engaging interactions that no one has experienced before. Without a
known-good cookbook recipe, a game AI programmer has to traverse uncharted
territory in search of good, usable emergent behavior. And of course, completely
new software agents do not come with guarantees as to what will emerge when
they interact. (Recall that the results Dr. Frankenstein achieved did not meet his