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);
    }
}
        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;
        }
Esempio n. 3
0
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;
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
/* 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;

}
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));



	
}
Esempio n. 8
0
 BaseLocationImpl::BaseLocationImpl(const BWAPI::TilePosition &tp)
 {
   tilePosition=tp;
   position=BWAPI::Position(tp.x()*32+64,tp.y()*32+48);
   island=false;
   region=NULL;
 }
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);
				}
			}
		}
	}
}
Esempio n. 10
0
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;
}
Esempio n. 11
0
 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));
           }
         }
       }
     }
   }
 }
Esempio n. 12
0
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;
}
Esempio n. 13
0
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;
}
Esempio n. 14
0
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())
		{
			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();
	}
}
Esempio n. 15
0
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;
}
Esempio n. 16
0
/* given top left tile position, draw box for width and height */
void EnhancedUI::drawBoxAtTilePositionToSize(BWAPI::TilePosition tpos, int width, int height)
{
	Broodwar->drawBoxMap(tpos.x() * 32, tpos.y() * 32, ((tpos.x() + width) * 32) - 1, 
		((tpos.y() + height) * 32) - 1, Colors::Purple, false);
}
Esempio n. 17
0
void EnhancedUI::drawTilePosition(BWAPI::TilePosition tPos, BWAPI::Color color) 
{
	Broodwar->drawBoxMap(tPos.x() * 32, tPos.y() * 32, tPos.x() * 32 + 31, 
		tPos.y() * 32 + 31, color, false);
}
Esempio n. 18
0
bool BaseManager::hasRefinery(BWTA::BaseLocation* location)
{
	bool refinery = false;

	//if base has gas
	if(location->isMineralOnly())
	{
		return false;
	}

	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;
}
Esempio n. 19
0
 bool isConnected(BWAPI::TilePosition a, BWAPI::TilePosition b)
 {
   if (getRegion(a)==NULL) return false;
   if (getRegion(b)==NULL) return false;
   return getRegion(a.x(),a.y())->isReachable(getRegion(b.x(),b.y()));
 }
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();
  }
}
Esempio n. 21
0
BWAPI::UnitType ReservedMap::getReservedType(BWAPI::TilePosition p)
{
  return reserveMap[p.x()][p.y()];
}
Esempio n. 22
0
void ReservedMap::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] = UnitTypes::None;
}