O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

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

Start Free Trial

No credit card required

Spin-offs
One great thing about a hierarchical goal-based arbitration design is that
extra features are provided with little additional effort from the program
-
mer. We’ll spend the remainder of the chapter taking a look at them.
Personalities
Because the desirability scores are constrained to the same range, it’s a
simple matter to create agents with different personality traits by multiply
-
ing each score with a constant that biases it in the required direction. For
instance, to create a Raven bot that plays aggressively with little regard for
its own safety, you can bias its desire to get health by 0.6 and its desire to
attack targets by 1.5. To create one that plays cautiously you can bias a
bot’s desires so it’s more likely to pick up weapons and health than attack.
If you were to design goal-directed agents for an RTS game you could cre-
ate one opponent that favors exploration and researching technology,
another that prefers to create huge armies as quickly as possible, and one
other that is obsessive about establishing city defenses.
To facilitate such personality traits, the
Goal_Evaluator base class con-
tains a member variable
m_dCharacterBias, which is assigned a value by
the client in the constructor like so:
class Goal_Evaluator
{
protected:
//when the desirability score for a goal has been evaluated it is multiplied
//by this value. It can be used to create bots with preferences based upon
//their personality
double m_dCharacterBias;
public:
Goal_Evaluator(double CharacterBias):m_dCharacterBias(CharacterBias){}
/* EXTRANEOUS DETAIL OMITTED */
};
m_dCharacterBias is utilized in the CalculateDesirability method of each
subclass to adjust the desirability score calculation. Here’s how it is added
to the desirability calculation for AttackTarget:
double AttackTargetGoal_Evaluator::CalculateDesirability(Raven_Bot* pBot)
{
double Desirability = 0.0;
//only do the calculation if there is a target present
if (pBot->GetTargetSys()->isTargetPresent())
{
const double Tweaker = 1.0;
Goal-Driven Agent Behavior
| 405
Spin-offs

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

Start Free Trial

No credit card required