Research Article
Artificial Intelligence in Video Games: Towards a Unified Framework
Algorithm 3
Primary tank designation. This function could be used to determine which unit or character should engage the enemy.
void set_tank(UnitList & grp) | { | //Get a list of the enemies the group is fighting | UnitList enemies = get_nearby_threats(grp); | Unit toughest = NULL; | double score = 0; | //For each unit in the group, estimate its toughness against the enemy | UnitList::iterator u; | for (u = grp.begin(); u != grp.end(); ++u) | { | double cs = score_tanking(u, grp, enemies); | if (cs > score) | { | toughest = u; | score = cs; | } | } | //Assign the role of tank to the toughest unit in the group | if (score > 0) | set_role(toughest, Role::tank); | } |
|