## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

//does not exceed the maximum force available to this vehicle, just
//possible without going over the max.
{
}
else
{
//add it to the steering force
}
return true;
}
Prioritized Dithering
In his paper, Reynolds suggests a method of force combination he calls pri-
oritized dithering. When used, this method checks to see if the first priority
behavior is going to be evaluated this simulation step, dependent on a pre-
set probability. If it is and the result is non-zero, the method returns the
calculated force and no other active behaviors are considered. If the result
is zero or if that behavior has been skipped over due to its probability of
being evaluated, the next priority behavior is considered and so on, for all
the active behaviors. This is a little snippet of code to help you understand
the concept:
SVector2D SteeringBehaviors::CalculateDithered()
{
//reset the steering force
m_vSteeringForce.Zero();
//the behavior probabilities
const double prWallAvoidance = 0.9;
const double prObstacleAvoidance = 0.9;
const double prSeparation = 0.8;
const double prAlignment = 0.5;
const double prCohesion = 0.5;
const double prWander = 0.8;
if (On(wall_avoidance) && RandFloat() > prWallAvoidance)
{
m_vSteeringForce = WallAvoidance(m_pVehicle->World()->Walls()) *
m_dWeightWallAvoidance / prWallAvoidance;
if (!m_vSteeringForce.IsZero())
{
m_vSteeringForce.Truncate(m_pVehicle->MaxForce());
return m_vSteeringForce;
How to Create Autonomously Moving Game Agents
| 123
Combining Steering Behaviors

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required