The newer versions of BWAPI provide access to internal Broodwar map region information.
As the API reference states:
“The Region class provides access to some of Broodwar's pathing information and offers members that can assist in navigation, scouting, construction, and information for key areas such as chokepoints. Though not always accurate, it is a lightweight alternative to BWTA that beginners can start with.
These regions are not so advanced as to cover everything up to a choke point with accurate polygons, but instead are small clusters of tiles connected to each other, kind of like a honeycomb.”
This could provide a more stable alternative to BWTA, which crashes on maps like Lost Temple.
I wrote this code to draw boxes around and print information about each region.
set<Region*> allRegions = Broodwar->getAllRegions();
BOOST_FOREACH(Region* bwRegion, allRegions)
{
Broodwar->drawBoxMap(bwRegion->getBoundsLeft(), bwRegion->getBoundsTop(),
bwRegion->getBoundsRight(), bwRegion->getBoundsBottom(), Colors::Yellow);
Broodwar->drawTextMap(bwRegion->getCenter().x(),bwRegion->getCenter().y(),
"Region [%d,%d] %d", bwRegion->getRegionGroupID(), bwRegion->getID()
,bwRegion->getDefensePriority());
}
Region->getDefensePriority() seems to indicate if the region is a choke, and how many other regions it branches into.
A BWAPI Region will commonly be placed around clumps of minerals.
|
This narrow intersection is divided into multiple Regions: one ‘3’ intersection and multiple 2’s.
|
A DefensePriority value of 2 indicates a bridge-type choke between two areas, and 3 is for a T-intersection choke. I have not seen any values of 4, but they may appear for a 4-way intersection.
This region just south of a mineral cluster is falsely identified as a chokepoint.
BWAPI regions are usually created around any impassable doodads, and given their own Group IDs.
|
The two doodads on the right have been clumped together into an impassable region. The impassable space tiles are also partitioned into a region group.
|
Another look at a 3-way intersection
|
The downside of BWAPI regions is the large amount of nesting and overlap occurring. However, it is interesting that impassable space and water tiles get their own regions, unlike BWTA regions.
On the upside, it should be safe to assume that every tile is covered with at least one BWAPI region. In contrast, BWTA Regions do not include impassable groups or choke points between two adjacent regions, returning a NULL pointer for getRegion().
I see, so if the regions are defined at a higher granularity(pixels or walktiles), they will appear to overlap when BuildTiles are checked to see which region they belong to. In fact it is probably better that they overlap, than to return null, as BWTA's getRegion does at times.
ReplyDeleteActually, to simplify display, I believe I simply drew a box around the top-most, left-most, right-most, and bottom-most tiles within each region. Each region is in fact not rectangular, and non-overlapping.
ReplyDelete