本文整理汇总了C++中bwapi::TilePosition类的典型用法代码示例。如果您正苦于以下问题:C++ TilePosition类的具体用法?C++ TilePosition怎么用?C++ TilePosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TilePosition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: operator
bool operator () (const BWAPI::TilePosition& position, const TileInformation& info) const
{
(void) info;
int minX = position.x() + lx;
if (minX < 0)
return false;
int maxX = position.x() + rx;
if (maxX >= mapWidth)
return false;
int minY = position.y() + ly;
if (minY < 0)
return false;
int maxY = position.y() + ry;
if (maxY >= mapHeight)
return false;
for(int x=minX; x<maxX; ++x)
for(int y=minY; y<maxY; ++y)
{
BWAPI::TilePosition pos(x, y);
TileInformation& subinfo = tileInformations[pos];
if (!tc(pos, subinfo))
return false;
}
return true;
}
开发者ID:LordBlackhawk,项目名称:bw-karl,代码行数:27,代码来源:arrangement-conditions.hpp
示例2: updateDepositCenterPosition
void BaseManager::updateDepositCenterPosition()
{
std::set<Base*> allBases = this->getAllBases();
if (allBases.size() <=1)
{
return;
}
for(std::set<Base*>::iterator b = allBases.begin(); b != allBases.end(); b++)
{
BWAPI::TilePosition tile = (*b)->getBaseLocation()->getTilePosition();
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->getUnitsOnTile(tile.x(),tile.y());
if (units.size() == 0)
{
UnitGroup commandCenters = SelectAll(BWAPI::UnitTypes::Terran_Command_Center).inRadius(400, (*b)->getBaseLocation()->getPosition());
if (commandCenters.size() > 0)
{
(*(commandCenters.begin()))->lift();
if ((*(commandCenters.begin()))->isLifted())
{
(*(commandCenters.begin()))->land(tile);
}
}
}
}
}
开发者ID:simingl,项目名称:IM_Debug_Terran_GA_Micro,代码行数:27,代码来源:BaseManager.cpp
示例3: hasRefinery
bool BaseManager::hasRefinery(BWTA::BaseLocation* location)
{
bool refinery = false;
//if base has gas
if(!(location->isMineralOnly()))
{
std::set<BWAPI::Unit*> basegeysers = location->getGeysers();
BWAPI::TilePosition geyserlocation;
//cycle through geysers & get tile location
for(std::set<BWAPI::Unit*>::iterator bg = basegeysers.begin(); bg != basegeysers.end(); bg++)
{
geyserlocation = (*bg)->getInitialTilePosition();
}
//check for refinery already on geyser
//get units on geyser
std::set<BWAPI::Unit*> unitsOnGeyser = BWAPI::Broodwar->getUnitsOnTile(geyserlocation.x(),geyserlocation.y());
//cycle through units on geyser
for(std::set<BWAPI::Unit*>::iterator u = unitsOnGeyser.begin(); u != unitsOnGeyser.end(); u++)
{
//if unit is a refinery
if ((*u)->getType().isRefinery())
{
refinery = true;
}
}
}
return refinery;
}
开发者ID:simingl,项目名称:IM_Debug_Terran_GA_Micro,代码行数:35,代码来源:BaseManager.cpp
示例4:
BaseLocationImpl::BaseLocationImpl(const BWAPI::TilePosition &tp)
{
tilePosition=tp;
position=BWAPI::Position(tp.x()*32+64,tp.y()*32+48);
island=false;
region=NULL;
}
开发者ID:Nerfling,项目名称:bwta,代码行数:7,代码来源:BaseLocationImpl.cpp
示例5: canBuildHere
bool BuildingPlacer::canBuildHere(BWAPI::TilePosition position, BWAPI::UnitType type) const
{
if (!BWAPI::Broodwar->canBuildHere(NULL, position, type))
return false;
for(int x = position.x(); x < position.x() + type.tileWidth(); x++)
for(int y = position.y(); y < position.y() + type.tileHeight(); y++)
if (reserveMap[x][y])
return false;
return true;
}
开发者ID:calebthompson,项目名称:School,代码行数:10,代码来源:BuildingPlacer.cpp
示例6: canBuildHere
bool BuildingPlacer::canBuildHere(BWAPI::TilePosition position, BWAPI::UnitType type) const
{
//returns true if we can build this type of unit here. Takes into account reserved tiles.
if (!BWAPI::Broodwar->canBuildHere(NULL, position, type))
return false;
for(int x = position.x(); x < position.x() + type.tileWidth(); x++)
for(int y = position.y(); y < position.y() + type.tileHeight(); y++)
if (reserveMap[x][y])
return false;
return true;
}
开发者ID:andertavares,项目名称:MegaBot,代码行数:11,代码来源:BuildingPlacer.cpp
示例7: assignWorkersToUnassignedBuildings
// STEP 2: ASSIGN WORKERS TO BUILDINGS WITHOUT THEM
void BuildingManager::assignWorkersToUnassignedBuildings()
{
// for each building that doesn't have a builder, assign one
buildingData.begin(ConstructionData::Unassigned);
while (buildingData.hasNextBuilding(ConstructionData::Unassigned))
{
Building & b = buildingData.getNextBuilding(ConstructionData::Unassigned);
if (debugMode) { BWAPI::Broodwar->printf("Assigning Worker To: %s", b.type.getName().c_str()); }
// remove all refineries after 3, i don't know why this happens
if (b.type.isRefinery() && (BWAPI::Broodwar->self()->allUnitCount(b.type) >= 3))
{
buildingData.removeCurrentBuilding(ConstructionData::Unassigned);
break;
}
// grab a worker unit from WorkerManager which is closest to this final position
BWAPI::UnitInterface* workerToAssign = WorkerManager::Instance().getBuilder(b);
// if the worker exists
if (workerToAssign)
{
//BWAPI::Broodwar->printf("VALID WORKER BEING ASSIGNED: %d", workerToAssign->getID());
// TODO: special case of terran building whose worker died mid construction
// send the right click command to the buildingUnit to resume construction
// skip the buildingsAssigned step and push it back into buildingsUnderConstruction
// set the worker we have assigned
b.builderUnit = workerToAssign;
// re-search for a building location with the builder unit ignored for space
BWAPI::TilePosition testLocation = getBuildingLocation(b);
// hopefully this will not blow up
if (!testLocation.isValid())
{
continue;
}
// set the final position of the building
b.finalPosition = testLocation;
// reserve this space
BuildingPlacer::Instance().reserveTiles(b.finalPosition, b.type.tileWidth(), b.type.tileHeight());
// this building has now been assigned
buildingData.addBuilding(ConstructionData::Assigned, b);
// remove this Building
buildingData.removeCurrentBuilding(ConstructionData::Unassigned);
}
}
}
开发者ID:NotABotBot,项目名称:ualbertabot,代码行数:55,代码来源:BuildingManager.cpp
示例8: canBuildHereWithSpace
bool BuildingPlacer::canBuildHereWithSpace(BWAPI::TilePosition position, BWAPI::UnitType type) const
{
if (!this->canBuildHere(position, type))
return false;
int width=type.tileWidth();
int height=type.tileHeight();
if (type==BWAPI::UnitTypes::Terran_Command_Center ||
type==BWAPI::UnitTypes::Terran_Factory ||
type==BWAPI::UnitTypes::Terran_Starport ||
type==BWAPI::UnitTypes::Terran_Science_Facility)
{
width+=2;
}
int startx = position.x() - buildDistance;
if (startx<0) startx=0;
int starty = position.y() - buildDistance;
if (starty<0) starty=0;
int endx = position.x() + width + buildDistance;
if (endx>BWAPI::Broodwar->mapWidth()) endx=BWAPI::Broodwar->mapWidth();
int endy = position.y() + height + buildDistance;
if (endy>BWAPI::Broodwar->mapHeight()) endy=BWAPI::Broodwar->mapHeight();
for(int x = startx; x < endx; x++)
for(int y = starty; y < endy; y++)
if (!type.isRefinery())
if (!buildable(x, y))
return false;
if (position.x()>3)
{
int startx2=startx-2;
if (startx2<0) startx2=0;
for(int x = startx2; x < startx; x++)
for(int y = starty; y < endy; y++)
{
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->unitsOnTile(x, y);
for(std::set<BWAPI::Unit*>::iterator i = units.begin(); i != units.end(); i++)
{
if (!(*i)->isLifted())
{
BWAPI::UnitType type=(*i)->getType();
if (type==BWAPI::UnitTypes::Terran_Command_Center ||
type==BWAPI::UnitTypes::Terran_Factory ||
type==BWAPI::UnitTypes::Terran_Starport ||
type==BWAPI::UnitTypes::Terran_Science_Facility)
{
return false;
}
}
}
}
}
return true;
}
开发者ID:calebthompson,项目名称:School,代码行数:54,代码来源:BuildingPlacer.cpp
示例9: assignWorkersToUnassignedBuildings
// STEP 2: ASSIGN WORKERS TO BUILDINGS WITHOUT THEM
void BuildingManager::assignWorkersToUnassignedBuildings()
{
// for each building that doesn't have a builder, assign one
for (Building & b : _buildings)
{
if (b.status != BuildingStatus::Unassigned)
{
continue;
}
if (_debugMode) { BWAPI::Broodwar->printf("Assigning Worker To: %s", b.type.getName().c_str()); }
if (createdHatchery && !isCreepStarted() && createdHatcheriesVector.size() >= 1 && startedPool)
{
//BWAPI::TilePosition myHatch = createdSunkenVector[0];
b.builderUnit = sunkenUnit;
}
else
{
BWAPI::Unit workerToAssign = WorkerManager::Instance().getBuilder(b);
if (workerToAssign)
{
b.builderUnit = workerToAssign;
}
}
//BWAPI::Broodwar->printf("VALID WORKER BEING ASSIGNED: %d", workerToAssign->getID());
// TODO: special case of terran building whose worker died mid construction
// send the right click command to the buildingUnit to resume construction
// skip the buildingsAssigned step and push it back into buildingsUnderConstruction
BWAPI::TilePosition testLocation = getBuildingLocation(b);
if (!testLocation.isValid())
{
continue;
}
b.finalPosition = testLocation;
// reserve this building's space
BuildingPlacer::Instance().reserveTiles(b.finalPosition, b.type.tileWidth(), b.type.tileHeight());
b.status = BuildingStatus::Assigned;
}
}
开发者ID:0x4849,项目名称:c350,代码行数:53,代码来源:BuildingManager.cpp
示例10: getBuildLocationNear
BWAPI::TilePosition BuildingPlacer::getBuildLocationNear(BWAPI::TilePosition position, BWAPI::UnitType type, int buildDist) const
{
//returns a valid build location near the specified tile position.
//searches outward in a spiral.
int x = position.x();
int y = position.y();
int length = 1;
int j = 0;
bool first = true;
int dx = 0;
int dy = 1;
while (length < BWAPI::Broodwar->mapWidth()) //We'll ride the spiral to the end
{
//if we can build here, return this tile position
if (x >= 0 && x < BWAPI::Broodwar->mapWidth() && y >= 0 && y < BWAPI::Broodwar->mapHeight())
if (this->canBuildHereWithSpace(BWAPI::TilePosition(x, y), type, buildDist))
return BWAPI::TilePosition(x, y);
//otherwise, move to another position
x = x + dx;
y = y + dy;
//count how many steps we take in this direction
j++;
if (j == length) //if we've reached the end, its time to turn
{
//reset step counter
j = 0;
//Spiral out. Keep going.
if (!first)
length++; //increment step counter if needed
//first=true for every other turn so we spiral out at the right rate
first =! first;
//turn counter clockwise 90 degrees:
if (dx == 0)
{
dx = dy;
dy = 0;
}
else
{
dy = -dx;
dx = 0;
}
}
//Spiral out. Keep going.
}
return BWAPI::TilePositions::None;
}
开发者ID:andertavares,项目名称:MegaBot,代码行数:51,代码来源:BuildingPlacer.cpp
示例11: buildPylon
void buildPylon(){
resourceSemaphore = true;
Unidade* nexus = Protoss_Nexus;
Unidade* worker = Protoss_Workers[numWorkers-1];
//nexus->getDistance();
//nexus->getPosition();
BWAPI::TilePosition aroundTile = nexus->getTilePosition();
int minDist = 8;
int stopDist = 40;
//debug("Pylon \n");
while(!worker->isConstructing()) {
for (int i=aroundTile.x(); (i<=aroundTile.x() + minDist) && !worker->isConstructing(); i++) {
for (int j=aroundTile.y(); (j<=aroundTile.y() + minDist) && !worker->isConstructing(); j++) {
//debug("1 Position: " + SSTR(i) + " " + SSTR(j) + "\n");
if (worker->isBuildable(BWAPI::TilePosition(i,j))) {
//debug("2 Position: " + SSTR(i) + " " + SSTR(j) + "\n");
worker->build(BWAPI::TilePosition(i,j),UnitTypes::Protoss_Pylon);
}
}
}
minDist+2;
}
resourceSemaphore = false;
// bool x = u->hasPower(3,4,50,60);
// u->isBuildable(50,50);
// u->isBuildable(BWAPI::TilePosition(3,5));
}
开发者ID:pedroneves,项目名称:bloodbath-and-beyond,代码行数:48,代码来源:MeuAgentePrincipal.cpp
示例12: getGroundDistanceMap
void getGroundDistanceMap(BWAPI::TilePosition start, RectangleArray<double>& distanceMap)
{
distanceMap.resize(BWAPI::Broodwar->mapWidth(),BWAPI::Broodwar->mapHeight());
Heap< BWAPI::TilePosition , int > heap(true);
for(unsigned int x=0;x<distanceMap.getWidth();x++) {
for(unsigned int y=0;y<distanceMap.getHeight();y++) {
distanceMap[x][y]=-1;
}
}
heap.push(std::make_pair(start,0));
int sx=(int)start.x();
int sy=(int)start.y();
distanceMap[sx][sy]=0;
while (!heap.empty()) {
BWAPI::TilePosition pos=heap.top().first;
int distance=heap.top().second;
heap.pop();
int x=(int)pos.x();
int y=(int)pos.y();
int min_x=max(x-1,0);
int max_x=min(x+1,distanceMap.getWidth()-1);
int min_y=max(y-1,0);
int max_y=min(y+1,distanceMap.getHeight()-1);
for(int ix=min_x;ix<=max_x;ix++) {
for(int iy=min_y;iy<=max_y;iy++) {
int f=abs(ix-x)*32+abs(iy-y)*32;
if (f>32) {f=45;}
int v=distance+f;
if (distanceMap[ix][iy]>v) {
heap.set(BWAPI::TilePosition(x,y),v);
distanceMap[ix][iy]=v;
} else {
if (distanceMap[ix][iy]==-1 && MapData::lowResWalkability[ix][iy]==true) {
distanceMap[ix][iy]=v;
heap.push(std::make_pair(BWAPI::TilePosition(ix,iy),v));
}
}
}
}
}
}
开发者ID:Nerfling,项目名称:bwta,代码行数:41,代码来源:BWTA.cpp
示例13: update
void BaseManager::update()
{
for(std::set<Base*>::iterator b = this->allBases.begin(); b != this->allBases.end(); b++)
{
if (!(*b)->isActive())
{
if ((*b)->getResourceDepot() == NULL)
{
BWAPI::TilePosition tile = (*b)->getBaseLocation()->getTilePosition();
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->unitsOnTile(tile.x(),tile.y());
for(std::set<BWAPI::Unit*>::iterator u = units.begin(); u != units.end(); u++)
if ((*u)->getPlayer() == BWAPI::Broodwar->self() && (*u)->getType().isResourceDepot())
{
(*b)->setResourceDepot(*u);
break;
}
}
if ((*b)->getResourceDepot()!=NULL)
if ((*b)->getResourceDepot()->isCompleted() || (*b)->getResourceDepot()->getRemainingBuildTime() < 250)
(*b)->setActive(true);
}
}
//check to see if any new base locations need to be added
for(std::set<BWTA::BaseLocation*>::const_iterator bl = BWTA::getBaseLocations().begin(); bl != BWTA::getBaseLocations().end(); bl++)
if (location2base.find(*bl) == location2base.end())
{
BWAPI::TilePosition tile = (*bl)->getTilePosition();
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->unitsOnTile(tile.x(), tile.y());
for(std::set<BWAPI::Unit*>::iterator u = units.begin(); u != units.end(); u++)
if ((*u)->getPlayer() == BWAPI::Broodwar->self() && (*u)->getType().isResourceDepot())
addBase(*bl);
}
}
开发者ID:geoffreyjourdain,项目名称:StarplannerLast,代码行数:34,代码来源:BaseManager.cpp
示例14: getRegionBoundingTilePositions
/* for a given BWTA region, finds corner tile positions for max width and height */
void EnhancedUI::getRegionBoundingTilePositions(const BWTA::Region * region, BWAPI::TilePosition & topLeftTP,
BWAPI::TilePosition & topRightTP, BWAPI::TilePosition & bottomRightTP,
BWAPI::TilePosition & bottomLeftTP)
{
BWTA::Polygon poly;
BWAPI::Position pLeft, pRight, pTop, pBottom;
/* tile sizes */
int tsLeft, tsTop, tsRight, tsBottom;
poly = region->getPolygon();
pLeft = pRight = pTop = pBottom = (Position) poly[0];
/* get bounds for BWTA region, map top left is (0,0) */
for(int j = 1; j < (int)poly.size(); j++)
{
if(poly[j].x() < pLeft.x()){
pLeft = poly[j];
}
if(poly[j].x() > pRight.x()){
pRight = poly[j];
}
if(poly[j].y() < pTop.y()){
pTop = poly[j];
}
if(poly[j].y() > pBottom.y()){
pBottom = poly[j];
}
}
/* align to tile sizes */
tsLeft = this->getMaxTileSize(pLeft.x());
tsTop = this->getMaxTileSize(pTop.y());
tsRight = this->getMinTileSize(pRight.x());
tsBottom = this->getMinTileSize(pBottom.y());
/* set tile positions */
topLeftTP.x() = tsLeft;
topLeftTP.y() = tsTop;
topRightTP.x() = tsRight;
topRightTP.y() = tsTop;
bottomRightTP.x() = tsRight;
bottomRightTP.y() = tsBottom;
bottomLeftTP.x() = tsLeft;
bottomLeftTP.y() = tsBottom;
}
开发者ID:arreiche,项目名称:CS-638-BWAPI,代码行数:51,代码来源:EnhancedUI.cpp
示例15: assignWorkersToUnassignedBuildings
// STEP 2: ASSIGN WORKERS TO BUILDINGS WITHOUT THEM
void BuildingManager::assignWorkersToUnassignedBuildings()
{
// for each building that doesn't have a builder, assign one
for (Building & b : _buildings)
{
if (b.status != BuildingStatus::Unassigned)
{
continue;
}
if (_debugMode) { BWAPI::Broodwar->printf("Assigning Worker To: %s",b.type.getName().c_str()); }
// grab a worker unit from WorkerManager which is closest to this final position
BWAPI::Unit workerToAssign = WorkerManager::Instance().getBuilder(b);
if (workerToAssign)
{
//BWAPI::Broodwar->printf("VALID WORKER BEING ASSIGNED: %d", workerToAssign->getID());
// TODO: special case of terran building whose worker died mid construction
// send the right click command to the buildingUnit to resume construction
// skip the buildingsAssigned step and push it back into buildingsUnderConstruction
b.builderUnit = workerToAssign;
BWAPI::TilePosition testLocation = getBuildingLocation(b);
if (!testLocation.isValid())
{
continue;
}
b.finalPosition = testLocation;
// reserve this building's space
BuildingPlacer::Instance().reserveTiles(b.finalPosition,b.type.tileWidth(),b.type.tileHeight());
b.status = BuildingStatus::Assigned;
}
}
}
开发者ID:ssssuishui,项目名称:SKBot,代码行数:41,代码来源:BuildingManager.cpp
示例16: getBuildLocationNear
BWAPI::TilePosition BuildingPlacer::getBuildLocationNear(BWAPI::TilePosition position, BWAPI::UnitType type) const
{
int x = position.x();
int y = position.y();
int length = 1;
int j = 0;
bool first = true;
int dx = 0;
int dy = 1;
while (length < BWAPI::Broodwar->mapWidth())
{
if (x >= 0 && x < BWAPI::Broodwar->mapWidth() && y >= 0 && y < BWAPI::Broodwar->mapHeight())
if (this->canBuildHereWithSpace(BWAPI::TilePosition(x, y), type))
return BWAPI::TilePosition(x, y);
x = x + dx;
y = y + dy;
j++;
if (j == length)
{
j = 0;
if (!first)
length++;
first =! first;
if (dx == 0)
{
dx = dy;
dy = 0;
}
else
{
dy = -dx;
dx = 0;
}
}
}
return BWAPI::TilePositions::None;
}
开发者ID:calebthompson,项目名称:School,代码行数:37,代码来源:BuildingPlacer.cpp
示例17: canBuildHereWithSpace
bool BuildingPlacer::canBuildHereWithSpace(BWAPI::TilePosition position, BWAPI::UnitType type, int buildDist) const
{
//returns true if we can build this type of unit here with the specified amount of space.
//space value is stored in this->buildDistance.
//if we can't build here, we of course can't build here with space
if (!this->canBuildHere(position, type))
return false;
int width=type.tileWidth();
int height=type.tileHeight();
//make sure we leave space for add-ons. These types of units can have addons:
if (type==BWAPI::UnitTypes::Terran_Command_Center ||
type==BWAPI::UnitTypes::Terran_Factory ||
type==BWAPI::UnitTypes::Terran_Starport ||
type==BWAPI::UnitTypes::Terran_Science_Facility)
{
width+=2;
}
int startx = position.x() - buildDist;
if (startx<0) return false;
int starty = position.y() - buildDist;
if (starty<0) return false;
int endx = position.x() + width + buildDist;
if (endx>BWAPI::Broodwar->mapWidth()) return false;
int endy = position.y() + height + buildDist;
if (endy>BWAPI::Broodwar->mapHeight()) return false;
if (!type.isRefinery())
{
for(int x = startx; x < endx; x++)
for(int y = starty; y < endy; y++)
if (!buildable(x, y) || reserveMap[x][y])
return false;
}
if (position.x()>3)
{
int startx2=startx-2;
if (startx2<0) startx2=0;
for(int x = startx2; x < startx; x++)
for(int y = starty; y < endy; y++)
{
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->getUnitsOnTile(x, y);
for(std::set<BWAPI::Unit*>::iterator i = units.begin(); i != units.end(); i++)
{
if (!(*i)->isLifted())
{
BWAPI::UnitType type=(*i)->getType();
if (type==BWAPI::UnitTypes::Terran_Command_Center ||
type==BWAPI::UnitTypes::Terran_Factory ||
type==BWAPI::UnitTypes::Terran_Starport ||
type==BWAPI::UnitTypes::Terran_Science_Facility)
{
return false;
}
}
}
}
}
return true;
}
开发者ID:andertavares,项目名称:MegaBot,代码行数:63,代码来源:BuildingPlacer.cpp
示例18: update
void BaseManager::update()
{
for(std::set<Base*>::iterator b = this->allBases.begin(); b != this->allBases.end(); b++)
{
if (!(*b)->isActive())
{
if ((*b)->getResourceDepot() == NULL)
{
BWAPI::TilePosition tile = (*b)->getBaseLocation()->getTilePosition();
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->getUnitsOnTile(tile.x(),tile.y());
for(std::set<BWAPI::Unit*>::iterator u = units.begin(); u != units.end(); u++)
if ((*u)->getPlayer() == BWAPI::Broodwar->self() && (*u)->getType().isResourceDepot())
{
(*b)->setResourceDepot(*u);
break;
}
}
if ((*b)->getResourceDepot()!=NULL)
{
if ((*b)->getResourceDepot()->exists()==false)
(*b)->setResourceDepot(NULL);
else
{
if ((*b)->getResourceDepot()->isCompleted() || (*b)->getResourceDepot()->getRemainingBuildTime() < 250)
(*b)->setActive(true);
}
}
}
//Set Refinerys
if (!(*b)->isActiveGas() && (*b)->hasGas())
{
if ((*b)->getRefinery() == NULL)
{
std::set<BWAPI::Unit*> baseGeysers = (*b)->getBaseLocation()->getGeysers();
BWAPI::TilePosition geyserLocation;
//cycle through geysers & get tile location
for(std::set<BWAPI::Unit*>::iterator bg = baseGeysers.begin(); bg != baseGeysers.end(); bg++)
{
geyserLocation = (*bg)->getTilePosition();
}
//check for refinery already on geyser
std::set<BWAPI::Unit*> unitsOnGeyser = BWAPI::Broodwar->getUnitsOnTile(geyserLocation.x(),geyserLocation.y());
for(std::set<BWAPI::Unit*>::iterator u = unitsOnGeyser.begin(); u != unitsOnGeyser.end(); u++)
{
if ((*u)->getPlayer() == BWAPI::Broodwar->self() && (*u)->getType().isRefinery())
{
(*b)->setRefinery(*u);
break;
}
}
}
if ((*b)->getRefinery() != NULL)
{
if ((*b)->getRefinery()->exists()==false)
(*b)->setResourceDepot(NULL);
else
{
if ((*b)->getRefinery()->isCompleted() || (*b)->getRefinery()->getRemainingBuildTime() < 250)
(*b)->setActiveGas(true);
}
}
}
}
//check to see if any new base locations need to be added
for(std::set<BWTA::BaseLocation*>::const_iterator bl = BWTA::getBaseLocations().begin(); bl != BWTA::getBaseLocations().end(); bl++)
{
if (location2base.find(*bl) == location2base.end())
{
BWAPI::TilePosition tile = (*bl)->getTilePosition();
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->getUnitsOnTile(tile.x(), tile.y());
for(std::set<BWAPI::Unit*>::iterator u = units.begin(); u != units.end(); u++)
if ((*u)->getPlayer() == BWAPI::Broodwar->self() && (*u)->getType().isResourceDepot())
addBase(*bl);
}
}
if(BWAPI::Broodwar->getFrameCount() % 500 == 0 && BWAPI::Broodwar->getFrameCount() >= 3000 && refineryBuildPriority > 0)
updateRefineries();
if (BWAPI::Broodwar->getFrameCount() %240 == 0 && BWAPI::Broodwar->getFrameCount() >= 5000)
{
updateAddons();
updateDepositCenterPosition();
}
}
开发者ID:simingl,项目名称:IM_Debug_Terran_GA_Micro,代码行数:92,代码来源:BaseManager.cpp
示例19: update
void BaseManager::update()
{
for(std::set<Base*>::iterator b = this->allBases.begin(); b != this->allBases.end(); b++)
{
Base *base = (*b);
// periodicky check, ci baza pouziva najblizsi resource depot
if (BWAPI::Broodwar->getFrameCount() % 300 == 231)
{
BWAPI::TilePosition tilePosition = base->getBaseLocation()->getTilePosition();
BWAPI::Position position = BWAPI::Position(tilePosition);
UnitGroup centers = UnitGroup::getUnitGroup(BWAPI::Broodwar->getUnitsInRadius(position, 600))
(BWAPI::Broodwar->self())
(isResourceDepot);
UnitGroup::iterator it;
BWAPI::Unit *nearestCenter = NULL;
double distance = 10000;
for (it = centers.begin(); it != centers.end(); it++)
{
BWAPI::Unit *centerCandidate = (*it);
dementor::Vector vector = dementor::Vector::fromPositions(position, centerCandidate->getPosition());
if (vector.getLength() < distance)
{
nearestCenter = centerCandidate;
distance = vector.getLength();
}
}
if (nearestCenter != NULL)
{
base->setResourceDepot(nearestCenter);
}
if (base->getResourceDepot() != NULL)
{
if (!base->getResourceDepot()->exists())
{
base->setResourceDepot(NULL);
}
else if (base->getResourceDepot()->isCompleted() || base->getResourceDepot()->getRemainingBuildTime() < 250)
{
base->setActive(true);
}
}
}
//Set Refinerys
if (!base->isActiveGas() && base->hasGas())
{
if (base->getRefinery() == NULL)
{
std::set<BWAPI::Unit*> baseGeysers = (*b)->getBaseLocation()->getGeysers();
BWAPI::TilePosition geyserLocation;
//cycle through geysers & get tile location
for(std::set<BWAPI::Unit*>::iterator bg = baseGeysers.begin(); bg != baseGeysers.end(); bg++)
{
geyserLocation = (*bg)->getTilePosition();
}
//check for refinery already on geyser
std::set<BWAPI::Unit*> unitsOnGeyser = BWAPI::Broodwar->getUnitsOnTile(geyserLocation.x(),geyserLocation.y());
for(std::set<BWAPI::Unit*>::iterator u = unitsOnGeyser.begin(); u != unitsOnGeyser.end(); u++)
{
BWAPI::Unit *unit = (*u);
if (unit->getPlayer() == BWAPI::Broodwar->self() && unit->getType().isRefinery())
{
base->setRefinery(*u);
break;
}
}
}
if (base->getRefinery() != NULL)
{
if (!base->getRefinery()->exists())
{
base->setResourceDepot(NULL);
}
else
{
if (base->getRefinery()->isCompleted() || base->getRefinery()->getRemainingBuildTime() < 250)
{
base->setActiveGas(true);
}
}
}
}
}
//check to see if any new base locations need to be added
for(std::set<BWTA::BaseLocation*>::const_iterator bl = BWTA::getBaseLocations().begin(); bl != BWTA::getBaseLocations().end(); bl++)
{
if (location2base.find(*bl) == location2base.end())
//.........这里部分代码省略.........
开发者ID:albertouri,项目名称:dementor-bot,代码行数:101,代码来源:BaseManager.cpp
示例20: freeTiles
void BuildingPlacer::freeTiles(BWAPI::TilePosition position, int width, int height)
{
for(int x = position.x(); x < position.x() + width && x < (int)reserveMap.getWidth(); x++)
for(int y = position.y(); y < position.y() + height && y < (int)reserveMap.getHeight(); y++)
reserveMap[x][y] = false;
}
开发者ID:calebthompson,项目名称:School,代码行数:6,代码来源:BuildingPlacer.cpp
注:本文中的bwapi::TilePosition类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论