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

#include <Commander.h>

Collaboration diagram for Commander:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~Commander ()
void computeActions ()
bool shallEngage ()
void updateGoals ()
void unitCreated (BaseAgent *agent)
void unitDestroyed (BaseAgent *agent)
bool needUnit (UnitType type)
SquadgetSquad (int id)
vector< Squad * > getSquads ()
TilePosition getClosestEnemyBuilding (TilePosition start)
int noOffensiveSquadsWithin (TilePosition center, int maxRange)
bool checkWorkersAttack (BaseAgent *base)
void assistBuilding (BaseAgent *building)
void assistWorker (BaseAgent *worker)
int enemyUnitsWithinRange (TilePosition start, int range)
void handleCloakedEnemy (TilePosition pos, Squad *squad)
void checkRemovableObstacles ()
void forceAttack ()
void printInfo ()
TilePosition findUnfortifiedChokePoint ()
TilePosition findChokePoint ()
bool isPowered (TilePosition pos)
bool isBuildable (TilePosition pos)
bool checkUnfinishedBuildings ()
bool checkRepairUnits ()
bool isImportantUnit (Unit *unit)
void repair (BaseAgent *agent)
void finishBuild (BaseAgent *agent)
void addBunkerSquad ()

Static Public Member Functions

static CommandergetInstance ()

Public Attributes

int ownDeadScore
int enemyDeadScore

Protected Member Functions

 Commander ()
TilePosition findOffensiveSquadPosition (TilePosition closeEnemy)

Protected Attributes

vector< Squad * > squads
int currentID
int currentState

Static Protected Attributes

static Commanderinstance = NULL
static const int DEFEND = 0
static const int ATTACK = 1

Detailed Description

The Commander class is the heart of deciding high level strategies like when and where to engage the enemy. It is responsible for deciding when to attack the enemy, where to attack him, and when a retreat is the best option to do. All units are grouped into Squads, and the Commander directs the different Squads to attack or defend positions. Each Squad are in turn responsible for handle the task it has been assigned.

The Commander is implemented as a singleton class. Each class that needs to access Commander can request an instance, and all classes shares the same Commander instance.

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


Constructor & Destructor Documentation

Commander::Commander ( ) [protected]

Here is the call graph for this function:

Here is the caller graph for this function:

Destructor.


Member Function Documentation

Adds a bunker squad when a Terran Bunker has been created.

Here is the call graph for this function:

Here is the caller graph for this function:

void Commander::assistBuilding ( BaseAgent building)

Tries to find a free squad to assist a building.

Here is the call graph for this function:

Here is the caller graph for this function:

void Commander::assistWorker ( BaseAgent worker)

Tries to find a free squad to assist a worker that is under attack.

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if there are any removable obstacles nearby, i.e. minerals with less than 20 resources left.

Here is the call graph for this function:

Here is the caller graph for this function:

Check if there are any important buildings or units to repair. Terran only.

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if there are any unfinished buildings that does not have an SCV working on them. Terran only.

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if workers needs to attack. Happens if base is under attack and no offensive units are available.

Here is the call graph for this function:

Here is the caller graph for this function:

Called each update to issue orders.

Here is the call graph for this function:

Here is the caller graph for this function:

int Commander::enemyUnitsWithinRange ( TilePosition  start,
int  range 
)

Counts the number of enemy units withing range from the start position.

Here is the call graph for this function:

Searches for and returns a good chokepoint position to defend the territory.

Here is the call graph for this function:

Here is the caller graph for this function:

Used to find where offensive attackin ground squads are, so air squads doesnt get ahead of other squads when attacking.

Here is the call graph for this function:

Here is the caller graph for this function:

Searches for a chokepoint that is unfortified, i.e. does not contain for example a Bunker or defensive turret. Returns TilePosition(-1, -1) if no position was found.

Here is the call graph for this function:

void Commander::finishBuild ( BaseAgent agent)

Assigns a worker to finish constructing an interrupted building. Terran only.

Here is the call graph for this function:

Here is the caller graph for this function:

Forces an attack, even if some squads are not full.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the position of the closest enemy building from the start position, or TilePosition(-1,-1) if not found.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the instance of the class.

Here is the call graph for this function:

Here is the caller graph for this function:

Squad * Commander::getSquad ( int  id)

Returns the Squad with the specified id, or NULL if not found.

Here is the caller graph for this function:

vector< Squad * > Commander::getSquads ( )

Returns all Squads.

Here is the caller graph for this function:

void Commander::handleCloakedEnemy ( TilePosition  pos,
Squad squad 
)

Called when own units are attacked by a cloaked enemy unit.

Here is the call graph for this function:

Here is the caller graph for this function:

Checks is a position is buildable.

Here is the call graph for this function:

bool Commander::isImportantUnit ( Unit unit)

Returns true if the unit is important to assist, false if not. All buildings and large expensive units such as siege tanks and battlecruisers are considered important, while small units such as marines and vultures are not considered important. Terran only.

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if a position is covered by psi (Protoss only).

Here is the call graph for this function:

bool Commander::needUnit ( UnitType  type)

Here is the caller graph for this function:

int Commander::noOffensiveSquadsWithin ( TilePosition  center,
int  maxRange 
)

Returns the number of active offensive squads within maxRange of the center position.

Shows some info on the screen.

Here is the call graph for this function:

Here is the caller graph for this function:

void Commander::repair ( BaseAgent agent)

Assigns a worker to repair the specified agent. Terran only.

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if it is time to engage the enemy. This happens when all Required squads are active.

Here is the call graph for this function:

Here is the caller graph for this function:

void Commander::unitCreated ( BaseAgent agent)

Called each time a unit is created. The unit is then placed in a Squad.

Called each time a unit is destroyed. The unit is then removed from its Squad.

Here is the call graph for this function:

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

const int Commander::ATTACK = 1 [static, protected]
int Commander::currentID [protected]
int Commander::currentState [protected]
const int Commander::DEFEND = 0 [static, protected]

The total killScore points of all enemy, destroyed units (not buildings).

Commander * Commander::instance = NULL [static, protected]

The total killScore points of all own, destroyed units (not buildings).

vector<Squad*> Commander::squads [protected]

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