Game Development Reference
In-Depth Information
A think rate of one thought per second proved slightly slow. The vehicles miss
opportunities that go by them as they daydream. This rate was still fast enough to
be safe, but the drivers sometimes appeared lethargic, letting openings go by that
they could have safely taken. A think rate as slow as one thought every two
seconds would have resulted in collisions or the possibility that some vehicles
could drive right through other vehicles in their lane. You can replicate the effects
of tuning the AI by completing the exercises at the end of the project.
The thinking speed not only has an impact on the AI, it has wider impacts that
need to be examined. AI is one part of the game, and all parts must balance. There
is give and take available among the major parts of the game; our simulation, as
simple as it is, has enough of the right elements to illustrate this.
If the AI can make certain demands of the simulated physics, our simulation
never has collisions. Once the code was debugged, collision detection was
restricted to the think cycle, not the animation cycle. Given the right physics and
a properly working AI, the collision detection can be skipped altogether. This is
an engineering decision balancing fun, realism, and computational demand. It
would clearly be unacceptable if there were humans driving any of the cars, for
Without certain guarantees, collisions could happen any time there is motion,
which asks that collision detection be performed every frame. During debugging,
collision detection was run every frame. Collision detection is physics, not AI, but
in a virtual world everything is under software control. When working properly,
our ''physics'' and AI provide certain guarantees that let us move collision
detection out of the animation loop and then make it completely optional. There
are three ways a vehicle can collide in our simulation: It can run into the back of a
slower vehicle in its lane, it can change lanes directly into another vehicle, or it
can change lanes into the path of an oncoming faster vehicle. We will look at the
impact of each of these.
Our AI looks forward two seconds' worth of travel distance at the vehicle's
current speed to see what it might hit in its lane. As long as what passes for
physics in our simulation allows the AI to cut the vehicle speed in half before the
next second of travel, a given vehicle will not collide when it comes up on a slower
vehicle already in its lane, even if that vehicle is at a dead stop. We get a realistic-
looking behavior with the fast drivers slowing down over many think cycles as
they come up on slow traffic and match speeds while keeping a safe distance. The
realism suffers when very high speed vehicles shed an unrealistic amount of speed
Search Nedrilad ::

Custom Search