BWAPI::Region class

Region objects are created by Starcraft: Broodwar to contain several tiles with the same properties, and create a node in pathfinding and other algorithms.

Contents

Regions may not contain detailed information, but have a sufficient amount of data to identify general chokepoints, accessibility to neighboring terrain, be used in general pathing algorithms, and used as nodes to rally units to.

Most parameters that are available are explicitly assigned by Broodwar itself.

Base classes

template<typename Interface, typename Data>
struct InterfaceDataWrapper<Region, RegionData>

Public functions

auto getBoundsBottom() const -> int
Retrieves the approximate bottom boundary of the region.
auto getBoundsLeft() const -> int
Retrieves the approximate left boundary of the region.
auto getBoundsRight() const -> int
Retrieves the approximate right boundary of the region.
auto getBoundsTop() const -> int
Retrieves the approximate top boundary of the region.
auto getCenter() const -> BWAPI::Position
Retrieves the center of the region.
auto getClosestAccessibleRegion() const -> BWAPI::Region
Retrieves the closest accessible neighbor region.
auto getClosestInaccessibleRegion() const -> BWAPI::Region
Retrieves the closest inaccessible neighbor region.
auto getDefensePriority() const -> int
Retrieves a value that represents the strategic advantage of this region relative to other regions.
auto getDistance(BWAPI::Region other) const -> int
Retrieves the center-to-center distance between two regions.
auto getNeighbors() const -> const Regionset
Retrieves the set of neighbor Regions that this one is connected to.
auto getRegionGroupID() const -> int
Retrieves a unique identifier for a group of regions that are all connected and accessible by each other.
auto getUnits(const UnitFilter& pred = nullptr) const -> Unitset
Retrieves a Unitset containing all the units that are in this region.
auto isAccessible() const -> bool
Retrieves the state of accessibility of the region.
auto isHigherGround() const -> bool
Checks if this region is part of higher ground.

Function documentation

int BWAPI::Region::getBoundsBottom() const

Retrieves the approximate bottom boundary of the region.

Returns The y coordinate, in pixels, of the approximate bottom boundary of the region.

int BWAPI::Region::getBoundsLeft() const

Retrieves the approximate left boundary of the region.

Returns The x coordinate, in pixels, of the approximate left boundary of the region.

int BWAPI::Region::getBoundsRight() const

Retrieves the approximate right boundary of the region.

Returns The x coordinate, in pixels, of the approximate right boundary of the region.

int BWAPI::Region::getBoundsTop() const

Retrieves the approximate top boundary of the region.

Returns The y coordinate, in pixels, of the approximate top boundary of the region.

BWAPI::Position BWAPI::Region::getCenter() const

Retrieves the center of the region.

Returns A Position indicating the center location of the Region, in pixels.

This position is used as the node of the region.

BWAPI::Region BWAPI::Region::getClosestAccessibleRegion() const

Retrieves the closest accessible neighbor region.

Returns The closest Region that is accessible.

BWAPI::Region BWAPI::Region::getClosestInaccessibleRegion() const

Retrieves the closest inaccessible neighbor region.

Returns The closest Region that is inaccessible.

int BWAPI::Region::getDefensePriority() const

Retrieves a value that represents the strategic advantage of this region relative to other regions.

Returns An integer indicating this region's strategic potential.

A value of 2 may indicate a possible choke point, and a value of 3 indicates a signficant strategic position.

int BWAPI::Region::getDistance(BWAPI::Region other) const

Retrieves the center-to-center distance between two regions.

Parameters
other The target Region to calculate distance to.
Returns The integer distance from this Region to other.

const Regionset BWAPI::Region::getNeighbors() const

Retrieves the set of neighbor Regions that this one is connected to.

Returns A reference to a Regionset containing the neighboring Regions.

int BWAPI::Region::getRegionGroupID() const

Retrieves a unique identifier for a group of regions that are all connected and accessible by each other.

Returns An integer that represents the group of regions that this one is attached to.

That is, all accessible regions will have the same group ID. This function is generally used to check if a path is available between two points in constant time.

Unitset BWAPI::Region::getUnits(const UnitFilter& pred = nullptr) const

Retrieves a Unitset containing all the units that are in this region.

Parameters
pred (optional) If this parameter is used, it is a UnitFilter or function predicate that will retrieve only the units whose attributes match the given criteria. If omitted, then a default value of nullptr is used, in which case there is no filter.
Returns A Unitset containing all units in this region that have met the requirements of pred.

Also has the ability to filter the units before the creation of the Unitset.

bool BWAPI::Region::isAccessible() const

Retrieves the state of accessibility of the region.

Returns true if ground units can traverse this region, and false if the tiles in this region are inaccessible or unwalkable.

The region is considered accessible if it can be accessed by ground units.

bool BWAPI::Region::isHigherGround() const

Checks if this region is part of higher ground.

Returns true if this region is part of strategic higher ground, and false otherwise.

Higher ground may be used in strategic placement of units and structures.