BWAPI 4.2.0 An API for interacting with Starcraft: Broodwar (1.16.1) |
Public Member Functions | |
virtual Playerset & | allies ()=0 |
virtual bool | canBuildHere (TilePosition position, UnitType type, Unit builder=nullptr, bool checkExplored=false)=0 |
virtual bool | canMake (UnitType type, Unit builder=nullptr) const =0 |
virtual bool | canResearch (TechType type, Unit unit=nullptr, bool checkCanIssueCommandType=true)=0 |
virtual bool | canUpgrade (UpgradeType type, Unit unit=nullptr, bool checkCanIssueCommandType=true)=0 |
virtual int | countdownTimer () const =0 |
virtual int | elapsedTime () const =0 |
virtual void | enableFlag (int flag)=0 |
virtual Playerset & | enemies ()=0 |
virtual Player | enemy () const =0 |
virtual const Regionset & | getAllRegions () const =0 |
virtual const Unitset & | getAllUnits () const =0 |
virtual int | getAPM (bool includeSelects=false) const =0 |
virtual double | getAverageFPS () const =0 |
virtual Unit | getBestUnit (const BestUnitFilter &best, const UnitFilter &pred, Position center=Positions::Origin, int radius=999999) const =0 |
TilePosition | getBuildLocation (UnitType type, TilePosition desiredPosition, int maxRange=64, bool creep=false) const |
virtual const Bulletset & | getBullets () const =0 |
virtual int | getClientVersion () const =0 |
Unit | getClosestUnit (Position center, const UnitFilter &pred=nullptr, int radius=999999) const |
virtual Unit | getClosestUnitInRectangle (Position center, const UnitFilter &pred=nullptr, int left=0, int top=0, int right=999999, int bottom=999999) const =0 |
int | getDamageFrom (UnitType fromType, UnitType toType, Player fromPlayer=nullptr, Player toPlayer=nullptr) const |
int | getDamageTo (UnitType toType, UnitType fromType, Player toPlayer=nullptr, Player fromPlayer=nullptr) const |
virtual const std::list< Event > & | getEvents () const =0 |
virtual Force | getForce (int forceID) const =0 |
virtual const Forceset & | getForces () const =0 |
virtual int | getFPS () const =0 |
virtual int | getFrameCount () const =0 |
virtual GameType | getGameType () const =0 |
virtual const Unitset & | getGeysers () const =0 |
virtual int | getGroundHeight (int tileX, int tileY) const =0 |
int | getGroundHeight (TilePosition position) const |
virtual int | getInstanceNumber () const =0 |
virtual bool | getKeyState (Key key) const =0 |
virtual Error | getLastError () const =0 |
virtual int | getLastEventTime () const =0 |
virtual int | getLatency () const =0 |
virtual int | getLatencyFrames () const =0 |
virtual int | getLatencyTime () const =0 |
virtual const Unitset & | getMinerals () const =0 |
virtual Position | getMousePosition () const =0 |
virtual bool | getMouseState (MouseButton button) const =0 |
virtual const Unitset & | getNeutralUnits () const =0 |
virtual const Position::list & | getNukeDots () const =0 |
virtual Player | getPlayer (int playerID) const =0 |
virtual const Playerset & | getPlayers () const =0 |
virtual unsigned | getRandomSeed () const =0 |
virtual Region | getRegion (int regionID) const =0 |
virtual BWAPI::Region | getRegionAt (int x, int y) const =0 |
BWAPI::Region | getRegionAt (BWAPI::Position position) const |
virtual int | getRemainingLatencyFrames () const =0 |
virtual int | getRemainingLatencyTime () const =0 |
virtual int | getReplayFrameCount () const =0 |
virtual int | getRevision () const =0 |
virtual BWAPI::Position | getScreenPosition () const =0 |
virtual const Unitset & | getSelectedUnits () const =0 |
virtual const TilePosition::list & | getStartLocations () const =0 |
virtual const Unitset & | getStaticGeysers () const =0 |
virtual const Unitset & | getStaticMinerals () const =0 |
virtual const Unitset & | getStaticNeutralUnits () const =0 |
virtual Unit | getUnit (int unitID) const =0 |
Unitset | getUnitsInRadius (int x, int y, int radius, const UnitFilter &pred=nullptr) const |
Unitset | getUnitsInRadius (BWAPI::Position center, int radius, const UnitFilter &pred=nullptr) const |
virtual Unitset | getUnitsInRectangle (int left, int top, int right, int bottom, const UnitFilter &pred=nullptr) const =0 |
Unitset | getUnitsInRectangle (BWAPI::Position topLeft, BWAPI::Position bottomRight, const UnitFilter &pred=nullptr) const |
Unitset | getUnitsOnTile (int tileX, int tileY, const UnitFilter &pred=nullptr) const |
Unitset | getUnitsOnTile (BWAPI::TilePosition tile, const UnitFilter &pred=nullptr) const |
virtual bool | hasCreep (int tileX, int tileY) const =0 |
bool | hasCreep (TilePosition position) const |
bool | hasPath (Position source, Position destination) const |
bool | hasPower (int tileX, int tileY, UnitType unitType=UnitTypes::None) const |
bool | hasPower (TilePosition position, UnitType unitType=UnitTypes::None) const |
bool | hasPower (int tileX, int tileY, int tileWidth, int tileHeight, UnitType unitType=UnitTypes::None) const |
bool | hasPower (TilePosition position, int tileWidth, int tileHeight, UnitType unitType=UnitTypes::None) const |
virtual bool | hasPowerPrecise (int x, int y, UnitType unitType=UnitTypes::None) const =0 |
bool | hasPowerPrecise (Position position, UnitType unitType=UnitTypes::None) const |
virtual Unit | indexToUnit (int unitIndex) const =0 |
virtual bool | isBattleNet () const =0 |
virtual bool | isBuildable (int tileX, int tileY, bool includeBuildings=false) const =0 |
bool | isBuildable (TilePosition position, bool includeBuildings=false) const |
virtual bool | isDebug () const =0 |
virtual bool | isExplored (int tileX, int tileY) const =0 |
bool | isExplored (TilePosition position) const |
virtual bool | isFlagEnabled (int flag) const =0 |
virtual bool | isGUIEnabled () const =0 |
virtual bool | isInGame () const =0 |
virtual bool | isLatComEnabled () const =0 |
virtual bool | isMultiplayer () const =0 |
virtual bool | isPaused () const =0 |
virtual bool | isReplay () const =0 |
virtual bool | issueCommand (const Unitset &units, UnitCommand command)=0 |
virtual bool | isVisible (int tileX, int tileY) const =0 |
bool | isVisible (TilePosition position) const |
virtual bool | isWalkable (int walkX, int walkY) const =0 |
bool | isWalkable (BWAPI::WalkPosition position) const |
virtual void | leaveGame ()=0 |
virtual std::string | mapFileName () const =0 |
virtual std::string | mapHash () const =0 |
virtual int | mapHeight () const =0 |
virtual std::string | mapName () const =0 |
virtual std::string | mapPathName () const =0 |
virtual int | mapWidth () const =0 |
virtual Player | neutral () const =0 |
virtual Playerset & | observers ()=0 |
virtual void | pauseGame ()=0 |
virtual void | pingMinimap (int x, int y)=0 |
void | pingMinimap (BWAPI::Position p) |
void | printf (const char *format,...) |
virtual void | restartGame ()=0 |
virtual void | resumeGame ()=0 |
virtual Player | self () const =0 |
void | sendText (const char *format,...) |
void | sendTextEx (bool toAllies, const char *format,...) |
virtual bool | setAlliance (BWAPI::Player player, bool allied=true, bool alliedVictory=true)=0 |
virtual void | setCommandOptimizationLevel (int level)=0 |
virtual void | setFrameSkip (int frameSkip)=0 |
virtual void | setGUI (bool enabled)=0 |
virtual bool | setLastError (BWAPI::Error e=Errors::None) const =0 |
virtual void | setLatCom (bool isEnabled)=0 |
virtual void | setLocalSpeed (int speed)=0 |
virtual bool | setMap (const char *mapFileName)=0 |
bool | setMap (const std::string &mapFileName) |
virtual bool | setRevealAll (bool reveal=true)=0 |
virtual void | setScreenPosition (int x, int y)=0 |
void | setScreenPosition (BWAPI::Position p) |
virtual bool | setVision (BWAPI::Player player, bool enabled=true)=0 |
virtual void | vPrintf (const char *format, va_list args)=0 |
void | vSendText (const char *format, va_list args) |
virtual void | vSendTextEx (bool toAllies, const char *format, va_list args)=0 |
Debugging Members | |
virtual void | setTextSize (Text::Size::Enum size=Text::Size::Default)=0 |
virtual void | vDrawText (CoordinateType::Enum ctype, int x, int y, const char *format, va_list arg)=0 |
void | drawText (CoordinateType::Enum ctype, int x, int y, const char *format,...) |
void | drawTextMap (int x, int y, const char *format,...) |
void | drawTextMap (Position p, const char *format,...) |
void | drawTextMouse (int x, int y, const char *format,...) |
void | drawTextMouse (Position p, const char *format,...) |
void | drawTextScreen (int x, int y, const char *format,...) |
void | drawTextScreen (Position p, const char *format,...) |
virtual void | drawBox (CoordinateType::Enum ctype, int left, int top, int right, int bottom, Color color, bool isSolid=false)=0 |
void | drawBoxMap (int left, int top, int right, int bottom, Color color, bool isSolid=false) |
void | drawBoxMap (Position leftTop, Position rightBottom, Color color, bool isSolid=false) |
void | drawBoxMouse (int left, int top, int right, int bottom, Color color, bool isSolid=false) |
void | drawBoxMouse (Position leftTop, Position rightBottom, Color color, bool isSolid=false) |
void | drawBoxScreen (int left, int top, int right, int bottom, Color color, bool isSolid=false) |
void | drawBoxScreen (Position leftTop, Position rightBottom, Color color, bool isSolid=false) |
virtual void | drawTriangle (CoordinateType::Enum ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid=false)=0 |
void | drawTriangleMap (int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid=false) |
void | drawTriangleMap (Position a, Position b, Position c, Color color, bool isSolid=false) |
void | drawTriangleMouse (int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid=false) |
void | drawTriangleMouse (Position a, Position b, Position c, Color color, bool isSolid=false) |
void | drawTriangleScreen (int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid=false) |
void | drawTriangleScreen (Position a, Position b, Position c, Color color, bool isSolid=false) |
virtual void | drawCircle (CoordinateType::Enum ctype, int x, int y, int radius, Color color, bool isSolid=false)=0 |
void | drawCircleMap (int x, int y, int radius, Color color, bool isSolid=false) |
void | drawCircleMap (Position p, int radius, Color color, bool isSolid=false) |
void | drawCircleMouse (int x, int y, int radius, Color color, bool isSolid=false) |
void | drawCircleMouse (Position p, int radius, Color color, bool isSolid=false) |
void | drawCircleScreen (int x, int y, int radius, Color color, bool isSolid=false) |
void | drawCircleScreen (Position p, int radius, Color color, bool isSolid=false) |
virtual void | drawEllipse (CoordinateType::Enum ctype, int x, int y, int xrad, int yrad, Color color, bool isSolid=false)=0 |
void | drawEllipseMap (int x, int y, int xrad, int yrad, Color color, bool isSolid=false) |
void | drawEllipseMap (Position p, int xrad, int yrad, Color color, bool isSolid=false) |
void | drawEllipseMouse (int x, int y, int xrad, int yrad, Color color, bool isSolid=false) |
void | drawEllipseMouse (Position p, int xrad, int yrad, Color color, bool isSolid=false) |
void | drawEllipseScreen (int x, int y, int xrad, int yrad, Color color, bool isSolid=false) |
void | drawEllipseScreen (Position p, int xrad, int yrad, Color color, bool isSolid=false) |
virtual void | drawDot (CoordinateType::Enum ctype, int x, int y, Color color)=0 |
void | drawDotMap (int x, int y, Color color) |
void | drawDotMap (Position p, Color color) |
void | drawDotMouse (int x, int y, Color color) |
void | drawDotMouse (Position p, Color color) |
void | drawDotScreen (int x, int y, Color color) |
void | drawDotScreen (Position p, Color color) |
virtual void | drawLine (CoordinateType::Enum ctype, int x1, int y1, int x2, int y2, Color color)=0 |
void | drawLineMap (int x1, int y1, int x2, int y2, Color color) |
void | drawLineMap (Position a, Position b, Color color) |
void | drawLineMouse (int x1, int y1, int x2, int y2, Color color) |
void | drawLineMouse (Position a, Position b, Color color) |
void | drawLineScreen (int x1, int y1, int x2, int y2, Color color) |
void | drawLineScreen (Position a, Position b, Color color) |
Protected Member Functions | |
Game & | operator= (const Game &other)=delete |
Game & | operator= (Game &&other)=delete |
The abstract Game class is implemented by BWAPI and is the primary means of obtaining all game state information from Starcraft Broodwar.
Game state information includes all units, resources, players, forces, bullets, terrain, fog of war, regions, etc.
Retrieves the set of all teams/forces.
Forces are commonly seen in Use Map Settings game types and some others such as Top vs Bottom and the team versions of game types.
Retrieves the set of all players in the match.
This includes the neutral player, which owns all the resources and critters by default.
Retrieves the set of all accessible units.
If Flag::CompleteMapInformation is enabled, then the set also includes units that are not visible to the player.
Retrieves the set of all accessible Mineral Fields in the game.
Retrieves the set of all accessible Vespene Geysers in the game.
Retrieves the set of all accessible neutral units in the game.
This includes Mineral Fields, Vespene Geysers, and Critters.
Retrieves the set of all Mineral Fields that were available at the beginning of the game.
Retrieves the set of all Vespene Geysers that were available at the beginning of the game.
Retrieves the set of all units owned by the neutral player (resources, critters, etc.) that were available at the beginning of the game.
Retrieves the set of all accessible bullets.
Retrieves the Force interface object associated with a given identifier.
forceID | The identifier for the Force object. |
forceID
. nullptr | if the given identifier is invalid. |
Retrieves the Player interface object associated with a given identifier.
playerID | The identifier for the Player object. |
playerID
. nullptr | if the given identifier is invalid. |
Retrieves the Unit interface object associated with a given identifier.
unitID | The identifier for the Unit object. |
unitID
. nullptr | if the given identifier is invalid. |
Retrieves a Unit interface object from a given unit index.
The value given as an index maps directly to Broodwar's unit array index and matches the index found in replay files. In order to use this function, CompleteMapInformation must be enabled.
unitIndex | The unitIndex to identify the Unit with. A valid index is 0 <= unitIndex & 0x7FF < 1700. |
unitIndex
. nullptr | if the given index is invalid. |
Retrieves the Region interface object associated with a given identifier.
regionID | The identifier for the Region object. |
regionID
. nullptr | if the given ID is invalid. |
Retrieves the current latency setting that the game is set to.
Latency indicates the delay between issuing a command and having it processed.
Retrieves the number of logical frames since the beginning of the match.
If the game is paused, then getFrameCount will not increase.
Retrieves the maximum number of logical frames that have been recorded in a replay.
If the game is not a replay, then the value returned is undefined.
Retrieves the logical frame rate of the game in frames per second (FPS).
Example:
Retrieves the average logical frame rate of the game in frames per second (FPS).
Retrieves the position of the user's mouse on the screen, in Position coordinates.
Positions::Unknown | if Flag::UserInput is disabled. |
Retrieves the state of the given mouse button.
button | A MouseButton enum member indicating which button on the mouse to check. |
button
. true if the button was pressed and false if it was not. false | always if Flag::UserInput is disabled. |
Retrieves the state of the given keyboard key.
key | A Key enum member indicating which key on the keyboard to check. |
key
. true if the key was pressed and false if it was not. false | always if Flag::UserInput is disabled. |
Retrieves the top left position of the viewport from the top left corner of the map, in pixels.
Positions::Unknown | always if Flag::UserInput is disabled. |
Moves the top left corner of the viewport to the provided position relative to the map's origin (top left (0,0)).
x | The x coordinate to move the screen to, in pixels. |
y | The y coordinate to move the screen to, in pixels. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Pings the minimap at the given position.
Minimap pings are visible to allied players.
x | The x coordinate to ping at, in pixels, from the map's origin (left). |
y | The y coordinate to ping at, in pixels, from the map's origin (top). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Checks if the state of the given flag is enabled or not.
flag | The Flag::Enum entry describing the flag's effects on BWAPI. |
flag
is enabled, false if the flag is disabled.Enables the state of a given flag.
flag | The Flag::Enum entry describing the flag's effects on BWAPI. |
nullptr
) constRetrieves the set of accessible units that are on a given build tile.
tileX | The X position, in tiles. |
tileY | The Y position, in tiles. |
pred | (optional) A function predicate that indicates which units are included in the returned set. |
nullptr
) constThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
nullptr
) const pure virtualRetrieves the set of accessible units that are in a given rectangle.
left | The X coordinate of the left position of the bounding box, in pixels. |
top | The Y coordinate of the top position of the bounding box, in pixels. |
right | The X coordinate of the right position of the bounding box, in pixels. |
bottom | The Y coordinate of the bottom position of the bounding box, in pixels. |
pred | (optional) A function predicate that indicates which units are included in the returned set. |
nullptr
) constThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
nullptr
) constRetrieves the set of accessible units that are within a given radius of a position.
x | The x coordinate of the center, in pixels. |
y | The y coordinate of the center, in pixels. |
radius | The radius from the center, in pixels, to include units. |
pred | (optional) A function predicate that indicates which units are included in the returned set. |
nullptr
) constThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
nullptr
, int radius = 999999
) constRetrieves the closest unit to center that matches the criteria of the callback pred within an optional radius.
center | The position to start searching for the closest unit. |
pred | (optional) The UnitFilter predicate to determine which units should be included. This includes all units by default. |
radius | (optional) The radius to search in. If omitted, the entire map will be searched. |
nullptr | If a suitable unit was not found. |
nullptr
, int left = 0
, int top = 0
, int right = 999999
, int bottom = 999999
) const pure virtualRetrieves the closest unit to center that matches the criteria of the callback pred within an optional rectangle.
center | The position to start searching for the closest unit. |
pred | (optional) The UnitFilter predicate to determine which units should be included. This includes all units by default. |
left | (optional) The left position of the rectangle. This value is 0 by default. |
top | (optional) The top position of the rectangle. This value is 0 by default. |
right | (optional) The right position of the rectangle. This value includes the entire map width by default. |
bottom | (optional) The bottom position of the rectangle. This value includes the entire map height by default. |
Positions::Origin
, int radius = 999999
) const pure virtualCompares all units with pred to determine which of them is the best.
All units are checked. If center and radius are specified, then it will check all units that are within the radius of the position.
best | A BestUnitFilter that determines which parameters should be considered when calculating which units are better than others. |
pred | A UnitFilter that determines which units to include in calculations. |
center | (optional) The position to use in the search. If omitted, then the entire map is searched. |
radius | (optional) The distance from center to search for units. If omitted, then the entire map is searched. |
nullptr | if a suitable unit was not found. |
Returns the last error that was set using setLastError.
If a function call in BWAPI has failed, you can use this function to retrieve the reason it failed.
Sets the last error so that future calls to getLastError will return the value that was set.
e | (optional) The error code to set. If omitted, then the last error will be cleared. |
true | If the type passed was Errors::None, clearing the last error. |
false | If any other error type was passed. |
Retrieves the width of the map in build tile units.
Retrieves the height of the map in build tile units.
Retrieves the file name of the currently loaded map.
Retrieves the full path name of the currently loaded map.
Retrieves the title of the currently loaded map.
Calculates the SHA-1 hash of the currently loaded map file.
Checks if the given mini-tile position is walkable.
walkX | The x coordinate of the mini-tile, in mini-tile units (8 pixels). |
walkY | The y coordinate of the mini-tile, in mini-tile units (8 pixels). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the ground height at the given tile position.
tileX | X position to query, in tiles |
tileY | Y position to query, in tiles |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
) const pure virtualChecks if a given tile position is buildable.
This means that, if all other requirements are met, a structure can be placed on this tile. This function uses static map data.
tileX | The x value of the tile to check. |
tileY | The y value of the tile to check. |
includeBuildings | (optional) If this is true, then this function will also check if any visible structures are occupying the space. If this value is false, then it only checks the static map data for tile buildability. This value is false by default. |
includeBuildings
was provided, then it will return false if a structure is currently occupying the tile. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Checks if a given tile position is visible to the current player.
tileX | The x value of the tile to check. |
tileY | The y value of the tile to check. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Checks if a given tile position has been explored by the player.
An explored tile position indicates that the player has seen the location at some point in the match, partially revealing the fog of war for the remainder of the match.
tileX | The x tile coordinate to check. |
tileY | The y tile coordinate to check. |
true | If the player has explored the given tile position (partially revealed fog). |
false | If the tile position was never explored (completely black fog). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Checks if the given tile position has Zerg creep on it.
tileX | The x tile coordinate to check. |
tileY | The y tile coordinate to check. |
true | If the given tile has creep on it. |
false | If the given tile does not have creep, or if it is concealed by the fog of war. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
UnitTypes::None
) const pure virtualChecks if the given pixel position is powered by an owned Protoss Pylon for an optional unit type.
x | The x pixel coordinate to check. |
y | The y pixel coordinate to check. |
unitType | (optional) Checks if the given UnitType requires power or not. If ommitted, then it will assume that the position requires power for any unit type. |
true | if the type at the given position will have power. |
false | if the type at the given position will be unpowered. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Checks if the given tile position if powered by an owned Protoss Pylon for an optional unit type.
tileX | The x tile coordinate to check. |
tileY | The y tile coordinate to check. |
unitType | (optional) Checks if the given UnitType will be powered if placed at the given tile position. If omitted, then only the immediate tile position is checked for power, and the function will assume that the location requires power for any unit type. |
true | if the type at the given tile position will receive power. |
false | if the type will be unpowered at the given tile position. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
UnitTypes::None
) constThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
UnitTypes::None
) constThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
nullptr
, bool checkExplored = false
) pure virtualChecks if the given unit type can be built at the given build tile position.
This function checks for creep, power, and resource distance requirements in addition to the tiles' buildability and possible units obstructing the build location.
position
. If the builder is not given, then the check for the addon will be conducted at position.type
is UnitTypes::Special_Start_Location, then the area for a resource depot (Command Center, Hatchery, Nexus) is checked as normal, but any potential obstructions (existing structures, creep, units, etc.) are ignored.position | Indicates the tile position that the top left corner of the structure is intended to go. |
type | The UnitType to check for. |
builder | (optional) The intended unit that will build the structure. If specified, then this function will also check if there is a path to the build site and exclude the builder from the set of units that may be blocking the build site. |
checkExplored | (optional) If this parameter is true, it will also check if the target position has been explored by the current player. This value is false by default, ignoring the explored state of the build site. |
Checks all the requirements in order to make a given unit type for the current player.
These include resources, supply, technology tree, availability, and required units.
type | The UnitType to check. |
builder | (optional) The Unit that will be used to build/train the provided unit type . If this value is nullptr or excluded, then the builder will be excluded in the check. |
builder
is provided, then it is only true if builder
can make the type
. Otherwise it will return false, indicating that the unit type can not be made. nullptr
, bool checkCanIssueCommandType = true
) pure virtualChecks all the requirements in order to research a given technology type for the current player.
These include resources, technology tree, availability, and required units.
type | The TechType to check. |
unit | (optional) The Unit that will be used to research the provided technology type . If this value is nullptr or excluded, then the unit will be excluded in the check. |
checkCanIssueCommandType | (optional) TODO fill this in |
unit
is provided, then it is only true if unit
can research the type
. Otherwise it will return false, indicating that the technology can not be researched. nullptr
, bool checkCanIssueCommandType = true
) pure virtualChecks all the requirements in order to upgrade a given upgrade type for the current player.
These include resources, technology tree, availability, and required units.
type | The UpgradeType to check. |
unit | (optional) The Unit that will be used to upgrade the provided upgrade type . If this value is nullptr or excluded, then the unit will be excluded in the check. |
checkCanIssueCommandType | (optional) TODO fill this in |
unit
is provided, then it is only true if unit
can upgrade the type
. Otherwise it will return false, indicating that the upgrade can not be upgraded. Retrieves the set of all starting locations for the current map.
A starting location is essentially a candidate for a player's spawn point.
Prints text to the screen as a notification.
This function allows text formatting using Text::Enum members. The behaviour of this function is the same as printf, located in header cstdio.
format | Text formatting. See std::printf for more information. Refrain from passing non-constant strings directly in this parameter. |
... | The arguments that will be formatted using the given text formatting. |
Prints text to the screen as a notification.
This function allows text formatting using Text::Enum members. The behaviour of this function is the same as printf, located in header cstdio.
format | Text formatting. See std::printf for more information. Refrain from passing non-constant strings directly in this parameter. |
... | The arguments that will be formatted using the given text formatting. |
This function is intended to forward an already-existing argument list.
args | The argument list that will be formatted. |
Sends a text message to all other players in the game.
The behaviour of this function is the same as std::printf, located in header cstdio.
format | Text formatting. See std::printf for more information. Refrain from passing non-constant strings directly in this parameter. |
Sends a text message to all other players in the game.
The behaviour of this function is the same as std::printf, located in header cstdio.
format | Text formatting. See std::printf for more information. Refrain from passing non-constant strings directly in this parameter. |
This function is intended to forward an already-existing argument list.
args | The argument list that will be formatted. |
An extended version of Game::sendText which allows messages to be forwarded to allies.
The behaviour of this function is the same as std::printf, located in header cstdio.
toAllies | If this parameter is set to true, then the message is only sent to allied players, otherwise it will be sent to all players. |
format | Text formatting. See std::printf for more information. Refrain from passing non-constant strings directly in this parameter. |
An extended version of Game::sendText which allows messages to be forwarded to allies.
The behaviour of this function is the same as std::printf, located in header cstdio.
toAllies | If this parameter is set to true, then the message is only sent to allied players, otherwise it will be sent to all players. |
format | Text formatting. See std::printf for more information. Refrain from passing non-constant strings directly in this parameter. |
This function is intended to forward an already-existing argument list.
args | The argument list that will be formatted. |
Checks if the current client is inside a game.
Checks if the current client is inside a multiplayer game.
Checks if the client is in a game that was created through the Battle.net multiplayer gaming service.
Checks if the current game is paused.
While paused, AIModule::onFrame will still be called.
Checks if the client is watching a replay.
Resumes the game from a paused state.
Leaves the current game by surrendering and enters the post-game statistics/score screen.
Restarts the match.
Works the same as if the match was restarted from the in-game menu (F10). This option is only available in single player games.
Sets the number of milliseconds Broodwar spends in each frame.
The default values are as follows:
speed | The time spent per frame, in milliseconds. A value of 0 indicates that frames are executed immediately with no delay. Negative values will restore the default value as listed above. |
Issues a given command to a set of units.
This function automatically splits the set into groups of 12 and issues the same command to each of them. If a unit is not capable of executing the command, then it is simply ignored.
units | A Unitset containing all the units to issue the command for. |
command | A UnitCommand object containing relevant information about the command to be issued. The Unit interface object associated with the command will be ignored. |
Retrieves the set of units that are currently selected by the user outside of BWAPI.
This function requires that Flag::UserInput be enabled.
Retrieves the player object that BWAPI is controlling.
nullptr | if the current game is a replay. |
Example usage
Retrieves the Player interface that represents the enemy player.
If there is more than one enemy, and that enemy is destroyed, then this function will still retrieve the same, defeated enemy. If you wish to handle multiple opponents, see the Game::enemies function.
nullptr | If there is no enemy or the current game is a replay. |
Retrieves the Player interface object representing the neutral player.
The neutral player owns all the resources and critters on the map by default.
Retrieves a set of all the current player's remaining allies.
Retrieves a set of all the current player's remaining enemies.
Retrieves a set of all players currently observing the game.
An observer is defined typically in a Use Map Settings game type as not having any impact on the game. This means an observer cannot start with any units, and cannot have any active trigger actions that create units for it.
Sets the size of the text for all calls to drawText following this one.
size | (optional) The size of the text. This value is one of Text::Size::Enum. If this value is omitted, then a default value of Text::Size::Default is used. |
Example usage
Draws text on the screen at the given coordinates.
Text can be drawn in different colors or formatted using the Text::Enum members.
ctype | The coordinate type. Indicates the relative position to draw the shape. |
x | The x coordinate, in pixels, relative to ctype. |
y | The y coordinate, in pixels, relative to ctype. |
format | The string formatting portion. This is the same as printf style formatting. |
arg | Arglist containing the intermediate list of arguments to format before finally sending the string to Broodwar. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
) pure virtualDraws a rectangle on the screen with the given color.
ctype | The coordinate type. Indicates the relative position to draw the shape. |
left | The x coordinate, in pixels, relative to ctype, of the left edge of the rectangle. |
top | The y coordinate, in pixels, relative to ctype, of the top edge of the rectangle. |
right | The x coordinate, in pixels, relative to ctype, of the right edge of the rectangle. |
bottom | The y coordinate, in pixels, relative to ctype, of the bottom edge of the rectangle. |
color | The color of the rectangle. |
isSolid | (optional) If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false. |
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
) pure virtualDraws a triangle on the screen with the given color.
ctype | The coordinate type. Indicates the relative position to draw the shape. |
ax | The x coordinate, in pixels, relative to ctype, of the first point. |
ay | The y coordinate, in pixels, relative to ctype, of the first point. |
bx | The x coordinate, in pixels, relative to ctype, of the second point. |
by | The y coordinate, in pixels, relative to ctype, of the second point. |
cx | The x coordinate, in pixels, relative to ctype, of the third point. |
cy | The y coordinate, in pixels, relative to ctype, of the third point. |
color | The color of the triangle. |
isSolid | (optional) If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false. |
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
) pure virtualDraws a circle on the screen with the given color.
ctype | The coordinate type. Indicates the relative position to draw the shape. |
x | The x coordinate, in pixels, relative to ctype. |
y | The y coordinate, in pixels, relative to ctype. |
radius | The radius of the circle, in pixels. |
color | The color of the circle. |
isSolid | (optional) If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
) pure virtualDraws an ellipse on the screen with the given color.
ctype | The coordinate type. Indicates the relative position to draw the shape. |
x | The x coordinate, in pixels, relative to ctype. |
y | The y coordinate, in pixels, relative to ctype. |
xrad | The x radius of the ellipse, in pixels. |
yrad | The y radius of the ellipse, in pixels. |
color | The color of the ellipse. |
isSolid | (optional) If true, then the shape will be filled and drawn as a solid, otherwise it will be drawn as an outline. If omitted, this value will default to false. |
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
false
)This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a dot on the map or screen with a given color.
ctype | The coordinate type. Indicates the relative position to draw the shape. |
x | The x coordinate, in pixels, relative to ctype. |
y | The y coordinate, in pixels, relative to ctype. |
color | The color of the dot. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a line on the map or screen with a given color.
ctype | The coordinate type. Indicates the relative position to draw the shape. |
x1 | The starting x coordinate, in pixels, relative to ctype. |
y1 | The starting y coordinate, in pixels, relative to ctype. |
x2 | The ending x coordinate, in pixels, relative to ctype. |
y2 | The ending y coordinate, in pixels, relative to ctype. |
color | The color of the line. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Retrieves the maximum delay, in number of frames, between a command being issued and the command being executed by Broodwar.
Retrieves the maximum delay, in milliseconds, between a command being issued and the command being executed by Broodwar.
Retrieves the number of frames it will take before a command sent in the current frame will be executed by the game.
Retrieves the number of milliseconds it will take before a command sent in the current frame will be executed by Broodwar.
Checks the state of latency compensation.
Changes the state of latency compensation.
Latency compensation modifies the state of BWAPI's representation of units to reflect the implications of issuing a command immediately after the command was performed, instead of waiting consecutive frames for the results. Latency compensation is enabled by default.
isEnabled | Set whether the latency compensation feature will be enabled (true) or disabled (false). |
Sets the rendering state of the Starcraft GUI.
This typically gives Starcraft a very low graphical frame rate and disables all drawing functionality in BWAPI.
enabled | A boolean value that determines the state of the GUI. Passing false to this function will disable the GUI, and true will enable it. |
Example Usage:
Retrieves the Starcraft instance number recorded by BWAPI to identify which Starcraft instance an AI module belongs to.
The very first instance should return 0.
false
) const pure virtualRetrieves the Actions Per Minute (APM) that the bot is producing.
includeSelects | (optional) If true, the return value will include selections as individual commands, otherwise it will exclude selections. This value is false by default. |
Changes the map to the one specified.
Once restarted, the game will load the map that was provided. Changes do not take effect unless the game is restarted.
mapFileName | A string containing the path and file name to the desired map. |
true | if the function succeeded and has changed the map. |
false | if the function failed, does not have permission from the tournament module, failed to find the map specified, or received an invalid parameter. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the number of graphical frames for every logical frame.
This allows the game to run more logical frames per graphical frame, increasing the speed at which the game runs.
frameSkip | Number of graphical frames per logical frame. If this value is 0 or less, then it will default to 1. |
Checks if there is a path from source to destination.
This only checks if the source position is connected to the destination position. This function does not check if all units can actually travel from source to destination. Because of this limitation, it has an O(1) complexity, and cases where this limitation hinders gameplay is uncommon at best.
source | The source position. |
destination | The destination position. |
true
, bool alliedVictory = true
) pure virtualSets the alliance state of the current player with the target player.
player | The target player to set alliance with. |
allied | (optional) If true, the current player will ally the target player. If false, the current player will make the target player an enemy. This value is true by default. |
alliedVictory | (optional) Sets the state of "allied victory". If true, the game will end in a victory if all allied players have eliminated their opponents. Otherwise, the game will only end if no other players are remaining in the game. This value is true by default. |
In a game, this function sets the vision of the current BWAPI player with the target player.
In a replay, this function toggles the visibility of the target player.
player | The target player to toggle vision. |
enabled | (optional) The vision state. If true, and in a game, the current player will enable shared vision with the target player, otherwise it will unshare vision. If in a replay, the vision of the target player will be shown, otherwise the target player will be hidden. This value is true by default. |
Retrieves current amount of time in seconds that the game has elapsed.
Sets the command optimization level.
Command optimization is a feature in BWAPI that tries to reduce the APM of the bot by grouping or eliminating unnecessary game actions. For example, suppose the bot told 24 Zerglings to Burrow. At command optimization level 0, BWAPI is designed to select each Zergling to burrow individually, which costs 48 actions. With command optimization level 1, it can perform the same behaviour using only 4 actions. The command optimizer also reduces the amount of bytes used for each action if it can express the same action using a different command. For example, Right_Click uses less bytes than Move.
level | An integer representation of the aggressiveness for which commands are optimized. A lower level means less optimization, and a higher level means more optimization. |
The values for level
are as follows:
Returns the remaining countdown time.
The countdown timer is used in Capture The Flag and Use Map Settings game types.
Example usage:
Retrieves the set of all regions on the map.
Retrieves the region at a given position.
x | The x coordinate, in pixels. |
y | The y coordinate, in pixels. |
nullptr | if the provided position is not valid (i.e. not within the map bounds). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Retrieves the amount of time (in milliseconds) that has elapsed when running the last AI module callback.
This is used by tournament modules to penalize AI modules that use too much processing time.
0 | When called from an AI module. |
true
) pure virtualSets the state of the fog of war when watching a replay.
reveal | (optional) The state of the reveal all flag. If false, all fog of war will be enabled. If true, then the fog of war will be revealed. It is true by default. |
64
, bool creep = false
) constRetrieves a basic build position just as the default Computer AI would.
This allows users to find simple build locations without relying on external libraries.
type | A valid UnitType representing the unit type to accomodate space for. |
desiredPosition | A valid TilePosition containing the desired placement position. |
maxRange | (optional) The maximum distance (in tiles) to build from desiredPosition . |
creep | (optional) A special boolean value that changes the behaviour of Creep Colony placement. |
TilePositions::Invalid | If a build location could not be found within maxRange . |
nullptr
, Player toPlayer = nullptr
) constCalculates the damage received for a given player.
It can be understood as the damage from fromType
to toType
. Does not include shields in calculation. Includes upgrades if players are provided.
fromType | The unit type that will be dealing the damage. |
toType | The unit type that will be receiving the damage. |
fromPlayer | (optional) The player owner of the given type that will be dealing the damage. If omitted, then no player will be used to calculate the upgrades for fromType . |
toPlayer | (optional) The player owner of the type that will be receiving the damage. If omitted, then this parameter will default to Broodwar->self(). |
nullptr
, Player fromPlayer = nullptr
) constCalculates the damage dealt for a given player.
It can be understood as the damage to toType
from fromType
. Does not include shields in calculation. Includes upgrades if players are provided.
toType | The unit type that will be receiving the damage. |
fromType | The unit type that will be dealing the damage. |
toPlayer | (optional) The player owner of the type that will be receiving the damage. If omitted, then no player will be used to calculate the upgrades for toType . |
fromPlayer | (optional) The player owner of the given type that will be dealing the damage. If omitted, then this parameter will default to Broodwar->self(). |
Retrieves the initial random seed that was used in this game's creation.
This is used to identify the seed that started this game, in case an error occurred, so that developers can deterministically reproduce the error. Works in both games and replays.