BWAPI
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
Squad Class Reference

#include <Squad.h>

Inheritance diagram for Squad:
Inheritance graph
[legend]
Collaboration diagram for Squad:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Squad ()
 Squad (int mId, int mType, int mMoveType, string mName, int mPriority)
int getID ()
void addRequirement (UnitType type, int no)
string getName ()
bool isRequired ()
void setRequired (bool mRequired)
int getPriority ()
void setPriority (int mPriority)
void setActivePriority (int mPriority)
void addSetup (UnitType type, int no)
vector< UnitSetupgetSetup ()
virtual bool isActive ()
void forceActive ()
bool isFull ()
int size ()
int getHealthPct ()
virtual void computeActions ()
bool isGathered ()
bool isAttacking ()
bool isUnderAttack ()
bool needUnit (UnitType type)
bool addMember (BaseAgent *agent)
vector< BaseAgent * > getMembers ()
void removeMember (BaseAgent *agent)
BaseAgentremoveMember (UnitType type)
virtual void setGoal (TilePosition mGoal)
virtual void clearGoal ()
virtual TilePosition getGoal ()
virtual bool hasGoal ()
bool isThisGoal (TilePosition mGoal)
bool isCloseTo (TilePosition mGoal)
TilePosition getCenter ()
BaseAgentgetCenterAgent ()
bool isOffensive ()
bool isDefensive ()
bool isExplorer ()
bool isBunkerDefend ()
bool isShuttle ()
bool isKite ()
bool isRush ()
bool isSupport ()
bool isGround ()
bool isAir ()
int getSize ()
int getTotalUnits ()
int getStrength ()
void disband (TilePosition retreatPoint)
virtual void printInfo ()
void printFullInfo ()
bool canMerge (Squad *squad)
bool hasUnits (UnitType type, int no)
bool contains (UnitType type)
TilePosition getClosestStartLocation (TilePosition pos)

Static Public Attributes

static const int OFFENSIVE = 0
static const int DEFENSIVE = 1
static const int EXPLORER = 2
static const int SUPPORT = 3
static const int BUNKER = 4
static const int SHUTTLE = 5
static const int KITE = 6
static const int RUSH = 7
static const int CHOKEHARASS = 8
static const int GROUND = 0
static const int AIR = 1

Protected Member Functions

void setMemberGoals ()
void setMemberState (BaseAgent *agent)
UnitfindTarget ()
void checkAttack ()
bool isVisible (TilePosition pos)
TilePosition getNextStartLocation ()

Protected Attributes

vector< BaseAgent * > agents
vector< UnitSetupsetup
TilePosition goal
int id
bool active
int type
int priority
int activePriority
int moveType
bool required
string name
int goalSetFrame
vector< TilePositionhasVisited

Detailed Description

The Squad class represents a squad of units with a shared goal, for example attacking the enemy or defending the base. The Squad can be built up from different combinations and numbers of UnitTypes.

Author: Johan Hagelback (johan.hagelback@gmail.com)


Constructor & Destructor Documentation

Default constructor.

Squad::Squad ( int  mId,
int  mType,
int  mMoveType,
string  mName,
int  mPriority 
)

Creates a squad with a unique id, a type (Offensive, Defensive, Exploration, Support), a movement type (Ground, Air) and a name (for example AirAttackSquad, MainGroundSquad). Higher priority squads gets filled before lower prio squads. Lower prio value is considered higher priority. A squad with priority of 1000 or more will not be built. This can be used to create one-time squads that are only filled once.


Member Function Documentation

bool Squad::addMember ( BaseAgent agent)

Adds an agent to this Squad.

Here is the call graph for this function:

Here is the caller graph for this function:

void Squad::addRequirement ( UnitType  type,
int  no 
)

Adds a requirement that needs to be fulfilled before this Squad is filled with units. For example (Protoss_Zealot, 10), then the Squad will be filled once 10 Zealots has been built.

void Squad::addSetup ( UnitType  type,
int  no 
)

Adds a setup for this Squad. Setup is a type and amount of units that shall be in this Squad.

Here is the caller graph for this function:

bool Squad::canMerge ( Squad squad)

Checks if this Squad can merge with the specified Squad. if they can, a merge is performed.

Here is the call graph for this function:

void Squad::checkAttack ( ) [protected]

Here is the call graph for this function:

Here is the caller graph for this function:

void Squad::clearGoal ( ) [virtual]

Clears the goal for this Squad, i.e. sets the goal to TilePosition(-1,-1).

Reimplemented in ShuttleSquad, KiteSquad, HarassSquad, ChokeHarassSquad, ExplorationSquad, and RushSquad.

Here is the call graph for this function:

void Squad::computeActions ( ) [virtual]

Called each update to issue orders.

Reimplemented in ShuttleSquad, KiteSquad, HarassSquad, ChokeHarassSquad, ExplorationSquad, and RushSquad.

Here is the call graph for this function:

bool Squad::contains ( UnitType  type)

Checks if the squad has at least one unit of the specified type.

Here is the call graph for this function:

void Squad::disband ( TilePosition  retreatPoint)

Disbands this Squad and send its remaining members to a retreat point.

Unit * Squad::findTarget ( ) [protected]

Here is the call graph for this function:

Here is the caller graph for this function:

Forces an offensive squad to be active, even if it's not full.

Returns the center position of this Squad, i.e. the average x and y position of its members.

Here is the caller graph for this function:

Returns the unit closest to the center position of the Squad.

Here is the call graph for this function:

Returns the closest start location to the specified position.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the current goal of this Squad.

Reimplemented in ShuttleSquad, KiteSquad, HarassSquad, ChokeHarassSquad, ExplorationSquad, and RushSquad.

Here is the caller graph for this function:

Returns the health percentage for this Squad. Health pct means how full the Squad is. An empty Squad returns 0, a full Squad 100 and a half full Squad 75.

Here is the caller graph for this function:

int Squad::getID ( )

Returns the id for this Squad.

Here is the caller graph for this function:

vector< BaseAgent * > Squad::getMembers ( )

Returns the members of this Squad.

string Squad::getName ( )

Returns the name of this Squad.

Here is the caller graph for this function:

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the priority for this Squad. Prio 1 is the highest.

Here is the caller graph for this function:

vector< UnitSetup > Squad::getSetup ( )

Returns all setups for this Squad. Each UnitType in the Squad is one setup.

int Squad::getSize ( )

Returns the size of the Squad, i.e. the number if agents currently in it.

Here is the caller graph for this function:

Returns the current strength of the Squad, i.e. the sum of the destroyScore() for all Squad members.

Returns the total number of units in the squad when it is full.

Here is the caller graph for this function:

bool Squad::hasGoal ( ) [virtual]

Returns true if this squad has an assigned goal.

Reimplemented in ShuttleSquad, KiteSquad, HarassSquad, ChokeHarassSquad, ExplorationSquad, and RushSquad.

Here is the call graph for this function:

bool Squad::hasUnits ( UnitType  type,
int  no 
)

Returns true if this Squad has the number of the specified unit types in it.

Here is the caller graph for this function:

bool Squad::isActive ( ) [virtual]

Returns true if this Squad is active, or false if not. A Squad is active when it first has been filled with agents. A Squad with destroyed units are still considered Active.

Reimplemented in ShuttleSquad, KiteSquad, HarassSquad, ChokeHarassSquad, ExplorationSquad, and RushSquad.

Here is the caller graph for this function:

bool Squad::isAir ( )

Returns true if this squad travels by air.

Here is the caller graph for this function:

Checks if the squad is attacking, i.e. if any member of the squad has targets within range.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns true if this is a Bunker Defense Squad.

bool Squad::isCloseTo ( TilePosition  mGoal)

Returns true if the goal of this squad is close to the specified goal.

Here is the call graph for this function:

Returns true if this is a Defensive Squad.

Here is the caller graph for this function:

Returns true if this is an Explorer Squad.

Here is the caller graph for this function:

bool Squad::isFull ( )

Returns true if this Squad is full, i.e. it has all the units it shall have.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns true if this Squad is gathered, i.e. if 90% of its units are within a certain range of each other.

Here is the call graph for this function:

bool Squad::isGround ( )

Returns true if this squad travels by ground.

Here is the caller graph for this function:

bool Squad::isKite ( )

Returns true if this is a Kite Squad.

Here is the caller graph for this function:

Returns true if this is an Offensive Squad.

Here is the caller graph for this function:

Checks if this Squad is required to be active before an attack is launched.

Here is the caller graph for this function:

bool Squad::isRush ( )

Returns true if this is a Rush Squad.

Here is the caller graph for this function:

bool Squad::isShuttle ( )

Returns true if this is a Shuttle Squad.

bool Squad::isSupport ( )

Returns true if this is a Support Squad (for example Transports).

Here is the caller graph for this function:

Returns true if the goal of this squad is the same as the specified goal, false if not.

Here is the call graph for this function:

Returns true if this Squad is under attack.

bool Squad::isVisible ( TilePosition  pos) [protected]

Here is the call graph for this function:

Here is the caller graph for this function:

bool Squad::needUnit ( UnitType  type)

Check if this Squad need units of the specified type.

Here is the call graph for this function:

Used to print some info to the screen. Shows printInfo() plus all members of the Squad.

Here is the call graph for this function:

Here is the caller graph for this function:

void Squad::printInfo ( ) [virtual]

Used to print some info to the screen.

Reimplemented in ShuttleSquad, KiteSquad, HarassSquad, ChokeHarassSquad, ExplorationSquad, and RushSquad.

Here is the call graph for this function:

Here is the caller graph for this function:

void Squad::removeMember ( BaseAgent agent)

Removes an agent from this Squad.

Here is the call graph for this function:

Here is the caller graph for this function:

Removes an agent of the specified type from this Squad, and returns the reference to the removed agent.

Here is the call graph for this function:

void Squad::setActivePriority ( int  mPriority)

Sets the priority this Squad has once it has been active. Prio 1 is the highest.

void Squad::setGoal ( TilePosition  mGoal) [virtual]

Sets the goal for this Squad.

Reimplemented in ShuttleSquad, KiteSquad, HarassSquad, ChokeHarassSquad, ExplorationSquad, and RushSquad.

Here is the call graph for this function:

Here is the caller graph for this function:

void Squad::setMemberGoals ( ) [protected]

Here is the caller graph for this function:

void Squad::setMemberState ( BaseAgent agent) [protected]

Here is the call graph for this function:

Here is the caller graph for this function:

void Squad::setPriority ( int  mPriority)

Sets the priority for this Squad. Prio 1 is the highest.

void Squad::setRequired ( bool  mRequired)

Sets if this Squad is required or not.

int Squad::size ( )

Returns the current size (i.e. number of alive agents in the squad).

Here is the caller graph for this function:


Member Data Documentation

bool Squad::active [protected]
int Squad::activePriority [protected]
vector<BaseAgent*> Squad::agents [protected]
const int Squad::AIR = 1 [static]

Air Squad

const int Squad::BUNKER = 4 [static]

Bunker Defense Squad

const int Squad::CHOKEHARASS = 8 [static]

ChokeHarass Squad

const int Squad::DEFENSIVE = 1 [static]

Defensive Squad

const int Squad::EXPLORER = 2 [static]

Explorer Squad

int Squad::goalSetFrame [protected]
const int Squad::GROUND = 0 [static]

Ground Squad

vector<TilePosition> Squad::hasVisited [protected]
int Squad::id [protected]
const int Squad::KITE = 6 [static]

Kite Squad

int Squad::moveType [protected]
string Squad::name [protected]
const int Squad::OFFENSIVE = 0 [static]

Offensive Squad

int Squad::priority [protected]
bool Squad::required [protected]
const int Squad::RUSH = 7 [static]

Rush Squad

vector<UnitSetup> Squad::setup [protected]
const int Squad::SHUTTLE = 5 [static]

Shuttle Squad

const int Squad::SUPPORT = 3 [static]

Support Squad

int Squad::type [protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines