BWAPI
|
#include <CoverMap.h>
Public Member Functions | |
~CoverMap () | |
void | addConstructedBuilding (Unit *unit) |
void | fillTemp (UnitType toBuild, TilePosition buildSpot) |
void | clearTemp (UnitType toBuild, TilePosition buildSpot) |
void | buildingDestroyed (Unit *unit) |
bool | canBuild (UnitType toBuild, TilePosition buildSpot) |
bool | positionFree (TilePosition pos) |
void | blockPosition (TilePosition buildSpot) |
TilePosition | findBuildSpot (UnitType toBuild) |
TilePosition | findRefineryBuildSpot (UnitType toBuild, TilePosition start) |
TilePosition | findClosestGasWithoutRefinery (UnitType toBuild, TilePosition start) |
TilePosition | searchRefinerySpot () |
TilePosition | findExpansionSite () |
void | debug () |
Static Public Member Functions | |
static CoverMap * | getInstance () |
Static Public Attributes | |
static const int | BUILDABLE = 1 |
static const int | BLOCKED = 0 |
static const int | TEMPBLOCKED = 4 |
static const int | MINERAL = 2 |
static const int | GAS = 3 |
The CoverMap class is used to keep track of the own base and which Tiles that are occupied by buildings, and which Tiles are free and possibly can be used to construct new buildings on.
Internally a matrix of the same size as the map is used. If a Tile is occupied or cant be reached by ground units, the value if the tile is 0. If the Tile can be built on, the value is 1. Buildings typically use up more space in the matrix than their actual size since we want some free space around each building. Different types of buildings have different space requirements.
The CoverMap is implemented as a singleton class. Each class that needs to access CoverMap can request an instance, and all classes shares the same CoverMap instance.
Author: Johan Hagelback (johan.hagelback@gmail.com)
Destructor
void CoverMap::addConstructedBuilding | ( | Unit * | unit | ) |
Adds a newly constructed building to the cover map.
void CoverMap::blockPosition | ( | TilePosition | buildSpot | ) |
Blocks a position from being used as a valid buildSpot. Used when a worker is timedout when moving towards the buildSpot.
void CoverMap::buildingDestroyed | ( | Unit * | unit | ) |
Called when a building is destroyed, to free up the space.
bool CoverMap::canBuild | ( | UnitType | toBuild, |
TilePosition | buildSpot | ||
) |
Checks if the specified building type can be built at the buildSpot. True if it can, false otherwise.
void CoverMap::clearTemp | ( | UnitType | toBuild, |
TilePosition | buildSpot | ||
) |
void CoverMap::debug | ( | ) |
Shows debug info on screen.
void CoverMap::fillTemp | ( | UnitType | toBuild, |
TilePosition | buildSpot | ||
) |
TilePosition CoverMap::findBuildSpot | ( | UnitType | toBuild | ) |
Finds and returns a buildSpot for the specified building type. If no buildspot is found, a TilePosition(-1,-1) is returned.
TilePosition CoverMap::findClosestGasWithoutRefinery | ( | UnitType | toBuild, |
TilePosition | start | ||
) |
Finds and returns the position of the closest free vespene gas around the specified start position. If no gas vein is found, a TilePosition(-1, -1) is returned.
Returns a position of a suitable site for expansion, i.e. new bases.
TilePosition CoverMap::findRefineryBuildSpot | ( | UnitType | toBuild, |
TilePosition | start | ||
) |
Searches for the closest vespene gas that is not in use. If no gas is sighted, the ExplorationManager is queried.
CoverMap * CoverMap::getInstance | ( | ) | [static] |
Returns the instance of the class.
bool CoverMap::positionFree | ( | TilePosition | pos | ) |
Checks if a position is free.
Searches for a spot to build a refinery at. Returns TilePosition(-1, -1) if no spot was found.
const int CoverMap::BLOCKED = 0 [static] |
Tile is blocked and cannot be built on.
const int CoverMap::BUILDABLE = 1 [static] |
Tile is buildable.
const int CoverMap::GAS = 3 [static] |
Tile contains a gas vein.
const int CoverMap::MINERAL = 2 [static] |
Tile contains a mineral vein.
const int CoverMap::TEMPBLOCKED = 4 [static] |
Tile is temporary blocked and cannot be built on.