Game Development Reference
In-Depth Information
The Mind of an Agent
The last class we need to establish is CAgent . This is where our AI decision-making
process will be taking place, of course. Before that, however, we need to establish
what our class looks like.
The CAgent class uses a pair of structs to help track its information. The first
one is for keeping track of the weapons that we have on our person.
struct sWEAPON_INFO
{
CWeapon* pWeapon;
USHORT Ammo;
};
typedef std::vector < sWEAPON_INFO > WEAPON_VECTOR;
Each item in a vector of type WEAPON_LIST contains a pointer to a weapon and
a record of the amount of ammunition that we carry for this weapon.
We also have a similar structure for our list of targets.
struct sTARGET_INFO
{
CDude* pDude;
CWeapon* pWeapon;
double Score;
bool operator<( const sTARGET_INFO& j ) {return Score > j.Score;}
};
typedef std::vector < sTARGET_INFO > TARGET_VECTOR;
The information contained in sTARGET_INFO may be confusing at first until we
discuss what our decision process will entail. We will be making a choice that is ac-
tually two in one. We must decide the best combination of which enemy we are
going to kill and with what weapon. As we touched on earlier in this chapter, decid-
ing on our target separately from the weapon we want to use may lead us to a false
“best solution.� Therefore, we have to address them as part of the same decision
process. Each entry that we place into a TARGET_LIST will be a combination of an
enemy and a weapon. We will then score that combination individually and select
the best entry.
Search WWH ::




Custom Search