Wiki
Clone wikiBWTA2 / BWTA
BWTA
Library header file: BWTA.h
Global functions:
- BWTA
- analyze
- cleanMemory()
- getRegions
- getChokepoints
- getBaseLocations
- getStartLocations
- getUnwalkablePolygons
- getStartLocation
- getRegion
- getNearestChokepoint
- getNearestBaseLocation
- getNearestUnwalkablePolygon
- getNearestUnwalkablePosition
- isConnected
- getGroundDistance
- getNearestTilePosition
- getGroundDistances
- getGroundDistanceMap
- getShortestPath
analyze
void analyze();
Before any other global functions can be called, the map must first be analyzed. Analyzing a starcraft map can take a long time, depending on your computer, so BWTA also automatically saves the results to a file when it is done. When you call analyze on the same map, BWTA will see that the results file for that map already exists, and load the results from file, rather than re-analyze the map.
cleanMemory()
void cleanMemory();
Clean all BWTA internal data structures. analyze()
calls it internally to avoid corrupted data on consecutive calls.
You should call this at the end of your program (usually a destructor).
getRegions
std::set<Region*>& getRegions();
Returns the set of regions in the map.
getChokepoints
std::set<Chokepoint*>& getChokepoints();
Returns the set of chokepoints in the map.
getBaseLocations
std::set<BaseLocation*>& getBaseLocations();
Returns the set of base locations on the map.
getStartLocations
std::set<BaseLocation*>& getStartLocations();
Returns the set of base locations that are start locations.
getUnwalkablePolygons
const std::set<Polygon*>& getUnwalkablePolygons();
Returns the set of unwalkable polygons.
getStartLocation
BaseLocation* getStartLocation(BWAPI::Player* player);
Given a pointer to a BWAPI::Player object, this function returns a pointer to the player's starting base location.
getRegion
Region* getRegion(int x, int y);
Region* getRegion(BWAPI::TilePosition tileposition);
Returns the region that the BWAPI::TilePosition is inside. Returns NULL if the tile position is not inside any valid region.
getNearestChokepoint
Chokepoint* getNearestChokepoint(int x, int y);
Chokepoint* getNearestChokepoint(BWAPI::TilePosition tileposition);
Chokepoint* getNearestChokepoint(BWAPI::Position position);
Returns the nearest chokepoint (in ground/walking distance). Returns NULL if no chokepoint is reachable from the given BWAPI::TilePosition (such as in an island component with no chokepoints). The BWAPI::Position version of this function has walk tile accuracy, while the other two have build tile accuracy.
getNearestBaseLocation
BaseLocation* getNearestBaseLocation(int x, int y);
BaseLocation* getNearestBaseLocation(BWAPI::TilePosition tileposition);
BaseLocation* getNearestBaseLocation(BWAPI::Position position);
Returns the nearest BaseLocation (in ground/walking distance). Returns NULL if no base location is reachable from the given BWAPI::TilePosition. The BWAPI::Position version of this function has walk tile accuracy, while the other two have build tile accuracy.
getNearestUnwalkablePolygon
Polygon* getNearestUnwalkablePolygon(int x, int y);
Polygon* getNearestUnwalkablePolygon(BWAPI::TilePosition tileposition);
Returns the nearest unwalkable Polygon. Note: The border of the map is not considered an unwalkable polygon.
getNearestUnwalkablePosition
BWAPI::Position getNearestUnwalkablePosition(BWAPI::Position position);
Returns the nearest BWAPI::Position that is on the boundary of an unwalkable Polygon, or border of the map.
isConnected
bool isConnected(int x1, int y1, int x2, int y2);
bool isConnected(BWAPI::TilePosition a, BWAPI::TilePosition b);
Returns true if there exists a static path between the two given BWAPI::TilePosition.
getGroundDistance
double getGroundDistance(BWAPI::TilePosition start, BWAPI::TilePosition end);
Returns the ground distance between the two given BWAPI::TilePosition.
getNearestTilePosition
std::pair<BWAPI::TilePosition, double> getNearestTilePosition(BWAPI::TilePosition start,
const std::set<BWAPI::TilePosition>& targets);
Returns the BWAPI::TilePosition in the given set that is closest to the given tile position, along with the ground distance to that tile position.
getGroundDistances
std::map<BWAPI::TilePosition, double> getGroundDistances(BWAPI::TilePosition start,
const std::set<BWAPI::TilePosition>& targets);
Returns the distance to each target tile position.
getGroundDistanceMap
void getGroundDistanceMap(BWAPI::TilePosition start, RectangleArray< double >& distanceMap);
Fills up the given RectangleArray distance map with the distance from the given tile position. Tiles not reachable from the given tile position will be set to -1.
getShortestPath
std::vector<BWAPI::TilePosition> getShortestPath(BWAPI::TilePosition start, BWAPI::TilePosition end);
Returns the shortest path from the start tile position to the end tile position. If no path exists, the vector will be empty.
std::vector<BWAPI::TilePosition> getShortestPath(BWAPI::TilePosition start,
const std::set<BWAPI::TilePosition>& targets);
Returns the shortest path from the start tile position to the closest target tile position. If no path exists to any of the target tile positions, the vector will be empty.
Updated