Ejemplo n.º 1
0
void MapDataReader::addEntry(string line)
{
    int i = line.find(" ");
    string t1 = line.substr(0, i);
    line = line.substr(i + 1, line.length());

    i = line.find(" ");
    string t2 = line.substr(0, i);
    line = line.substr(i + 1, line.length());

    i = line.find(" ");
    string t3 = line.substr(0, i);
    line = line.substr(i + 1, line.length());

    i = line.find(" ");
    string t4 = line.substr(0, i);
    line = line.substr(i + 1, line.length());

    string t5 = line;

    MapData entry;
    entry.basePos = TilePosition(toInt(t1), toInt(t2));
    entry.pos = TilePosition(toInt(t3), toInt(t4));
    entry.dist = toInt(t5);

    data.push_back(entry);
}
Ejemplo n.º 2
0
TilePosition Squad::getNextStartLocation()
{
	for(set<BaseLocation*>::const_iterator i=getStartLocations().begin();i!=getStartLocations().end();i++)
	{
		TilePosition basePos = (*i)->getTilePosition();
		if (!isVisible(basePos))
		{
			return basePos;
		}
		else
		{
			if ((int)agents.size() > 0)
			{
				UnitAgent* uagent = (UnitAgent*)agents.at(0);
				int eCnt = uagent->enemyUnitsWithinRange(10 * 32);
				if (eCnt > 0)
				{
					return TilePosition(-1, -1);
				}
			}

			hasVisited.push_back(basePos);
		}
	}
	return TilePosition(-1, -1);
}
Ejemplo n.º 3
0
TilePosition Commander::findUnfortifiedChokePoint()
{
	double bestDist = 0;
	Chokepoint* bestChoke = NULL;

	for(set<BWTA::Region*>::const_iterator i=getRegions().begin();i!=getRegions().end();i++)
	{
		if (isOccupied((*i)))
		{
			for(set<Chokepoint*>::const_iterator c=(*i)->getChokepoints().begin();c!=(*i)->getChokepoints().end();c++)
			{
				if (isEdgeChokepoint((*c)))
				{
					if (!chokePointFortified(TilePosition((*c)->getCenter())))
				{
						double cDist = Broodwar->self()->getStartLocation().getDistance(TilePosition((*c)->getCenter()));
						if (cDist > bestDist)
				{
							bestDist = cDist;
							bestChoke = (*c);
						}
					}
				}
			}
		}
	}

	TilePosition buildPos = TilePosition(-1, -1);
	if (bestChoke != NULL)
	{
		buildPos = TilePosition(bestChoke->getCenter());
	}
	return buildPos;
}
Ejemplo n.º 4
0
TilePosition StructureAgent::getNextScanLocation()
{
	TilePosition ePos = ExplorationManager::getInstance()->getClosestSpottedBuilding(Broodwar->self()->getStartLocation());
	if (ePos.x() > -1)
	{
		//Already found enemy base
		return TilePosition(-1, -1);
	}

	for(set<BaseLocation*>::const_iterator i=getStartLocations().begin();i!=getStartLocations().end();i++)
	{
		TilePosition basePos = (*i)->getTilePosition();

		bool needScan = true;

		//1. Check previous scans
		for (int i = 0; i < (int)hasScanned.size(); i++)
		{
			if (hasScanned.at(i).x() == basePos.x() && hasScanned.at(i).y() == basePos.y())
			{
				needScan = false;
			}
		}

		//2. Check if we have this base
		vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents();
		for (int i = 0; i < (int)agents.size(); i++)
		{
			if (agents.at(i)->isAlive())
			{
				double dist = basePos.getDistance(agents.at(i)->getUnit()->getTilePosition());
				if (dist <= 10)
				{
					needScan = false;
					break;
				}
			}
		}

		//3. Check if enemy units are near
		for(set<Unit*>::const_iterator j=Broodwar->enemy()->getUnits().begin();j!=Broodwar->enemy()->getUnits().end();j++)
		{
			if ((*j)->exists())
			{
				double dist = basePos.getDistance((*j)->getTilePosition());
				if (dist <= 10)
				{
					needScan = false;
					break;
				}
			}
		}

		if (needScan)
		{
			return basePos;
		}
	}
	return TilePosition(-1, -1);
}
Ejemplo n.º 5
0
void Monster::FindPath(Tile* p_start, Tile* p_goal)
{
    Tile* toCheck[4];

    vector<AstarItem> queue;
    vector<AstarItem> visited;

    AstarItem first;
    first.toStart = 0;
    TilePosition startdif = p_goal->getTilePosition() - p_start->getTilePosition();
    first.toGoal = abs(startdif.x) + abs(startdif.y);
    first.tile = p_start;
    first.parent = NULL;
    queue.push_back(first);
    while (queue.size() > 0 && queue.back().tile != p_goal)
    {
        visited.push_back(queue.back());
        TilePosition p = queue.back().tile->getTilePosition();
        queue.pop_back();
        toCheck[0] = m_map->getTile(p + TilePosition(0, 1));
        toCheck[1] = m_map->getTile(p + TilePosition(0, -1));
        toCheck[2] = m_map->getTile(p + TilePosition(1, 0));
        toCheck[3] = m_map->getTile(p + TilePosition(-1, 0));
        for (int i = 0; i < 4; i++)
        {
            if (toCheck[i])
            {
                bool skip = !toCheck[i]->isFree();
                for (unsigned int j = 0; j < visited.size(); j++)
                {
                    if (visited[j].tile == toCheck[i])
                        skip = true;
                }
                if (!skip)
                {
                    int toStart = visited.back().toStart+1;
                    TilePosition dif = p_goal->getTilePosition() - toCheck[i]->getTilePosition();
                    int toGoal = abs(dif.x) + abs(dif.y);
                    UpdateQueue(toCheck[i], visited.size()-1, toStart, toGoal, queue);
                }
            }
        }
    }

    if (queue.size() == 0)
        return;

    m_path.clear();
    m_path.push_back(queue.back().tile);
    int parent = queue.back().parent;
    while (m_path.back() != p_start)
    {
        AstarItem asi = visited[parent];
        m_path.push_back(asi.tile);
        parent = asi.parent;
    }

    return;
}
Ejemplo n.º 6
0
UINT RenderCache::Paint(HDC hdc, RectI bounds, DisplayModel *dm, int pageNo,
                        PageInfo *pageInfo, bool *renderOutOfDateCue)
{
    assert(pageInfo->shown && 0.0 != pageInfo->visibleRatio);

    int rotation = dm->Rotation();
    float zoom = dm->ZoomReal();
    USHORT targetRes = GetTileRes(dm, pageNo);
    USHORT maxRes = GetMaxTileRes(dm, pageNo, rotation);
    if (maxRes < targetRes)
        maxRes = targetRes;

    Vec<TilePosition> queue;
    queue.Append(TilePosition(0, 0, 0));
    UINT renderDelayMin = RENDER_DELAY_UNDEFINED;
    bool neededScaling = false;

    while (queue.Count() > 0) {
        TilePosition tile = queue.At(0);
        queue.RemoveAt(0);
        RectI tileOnScreen = GetTileOnScreen(dm->engine, pageNo, rotation, zoom, tile, pageInfo->pageOnScreen);
        tileOnScreen = pageInfo->pageOnScreen.Intersect(tileOnScreen);
        RectI isect = bounds.Intersect(tileOnScreen);
        if (isect.IsEmpty())
            continue;

        bool isTargetRes = tile.res == targetRes;
        UINT renderDelay = PaintTile(hdc, isect, dm, pageNo, tile, tileOnScreen, isTargetRes,
                                     renderOutOfDateCue, isTargetRes ? &neededScaling : NULL);
        if (!(isTargetRes && 0 == renderDelay) && tile.res < maxRes) {
            queue.Append(TilePosition(tile.res + 1, tile.row * 2, tile.col * 2));
            queue.Append(TilePosition(tile.res + 1, tile.row * 2, tile.col * 2 + 1));
            queue.Append(TilePosition(tile.res + 1, tile.row * 2 + 1, tile.col * 2));
            queue.Append(TilePosition(tile.res + 1, tile.row * 2 + 1, tile.col * 2 + 1));
        }
        if (isTargetRes && renderDelay > 0)
            neededScaling = true;
        renderDelayMin = min(renderDelay, renderDelayMin);
        // paint tiles from left to right from top to bottom
        if (tile.res > 0 && queue.Count() > 0 && tile.res < queue.At(0).res)
            queue.Sort(cmpTilePosition);
    }

#ifdef CONSERVE_MEMORY
    if (!neededScaling) {
        if (renderOutOfDateCue)
            *renderOutOfDateCue = false;
        // free tiles with different resolution
        TilePosition tile(targetRes, (USHORT)-1, 0);
        FreePage(dm, pageNo, &tile);
    }
    FreeNotVisible();
#endif

    return renderDelayMin;
}
Ejemplo n.º 7
0
TilePosition CoverMap::findBuildSpot(UnitType toBuild, TilePosition start)
{
	//Check start pos
	if (canBuildAt(toBuild, start)) return start;

	//Search outwards
	bool found = false;
	int cDiff = 1;
	TilePosition spot = TilePosition(-1, -1);
	while (!found) 
	{
		//Top
		TilePosition s = TilePosition(start.x() - cDiff, start.y() - cDiff);
		TilePosition e = TilePosition(start.x() + cDiff, start.y() - cDiff);
		spot = findSpotAtSide(toBuild, s, e);
		if (spot.x() != -1 && spot.y() != -1)
		{
			found = true;
			break;
		}

		//Bottom
		s = TilePosition(start.x() - cDiff, start.y() + cDiff);
		e = TilePosition(start.x() + cDiff, start.y() + cDiff);
		spot = findSpotAtSide(toBuild, s, e);
		if (spot.x() != -1 && spot.y() != -1)
		{
			found = true;
			break;
		}

		//Left
		s = TilePosition(start.x() - cDiff, start.y() - cDiff);
		e = TilePosition(start.x() - cDiff, start.y() + cDiff);
		spot = findSpotAtSide(toBuild, s, e);
		if (spot.x() != -1 && spot.y() != -1)
		{
			found = true;
			break;
		}

		//Right
		s = TilePosition(start.x() + cDiff, start.y() - cDiff);
		e = TilePosition(start.x() + cDiff, start.y() + cDiff);
		spot = findSpotAtSide(toBuild, s, e);
		if (spot.x() != -1 && spot.y() != -1)
		{
			found = true;
			break;
		}

		cDiff++;
		if (cDiff > range) found = true;
	}
	
	return spot;
}
Bomb* GOFactory::CreateBomb(Tile* p_tile, Tilemap* p_map)
{
	vector<pair<Tile*, SpriteInfo*> > flames;

	fVector3 pos = GetCenter(p_tile, 0.6f); 
	fVector2 size = GetScaledSize(p_tile, 1.2f);
	Rect r;
	r.x = 0;
	r.y = 0;
	r.height = 64;
	r.width = 64;
	SpriteInfo* spriteInfo = CreateSpriteInfo("../Textures/Explosion_Animation.png",
		pos, size, &r);
	flames.push_back(pair<Tile*, SpriteInfo*>(p_tile, spriteInfo));

	TilePosition dir[] = {TilePosition(1, 0), TilePosition(-1, 0), TilePosition(0, 1), TilePosition(0, -1)};
	for (int i = 0; i < 4; i++)
	{
		Tile* curr = p_map->getTile(p_tile->getTilePosition() + dir[i]);
		while (curr && curr->isFree())
		{
			pos = GetCenter(curr, 0.6f); 
			size = GetScaledSize(curr, 1.2f);

			r.x = 0;
			r.y = 0;
			r.height = 64;
			r.width = 64;
			SpriteInfo* spriteInfo = CreateSpriteInfo("../Textures/Explosion_Animation.png",
				pos, size, &r);

			flames.push_back(pair<Tile*, SpriteInfo*>(curr, spriteInfo));
			curr = p_map->getTile(curr->getTilePosition() + dir[i]);
		}
	}

	pos = GetCenter(p_tile, 0.19f); 
	size = GetScaledSize(p_tile, 2.0f);

	Rect br;
	br.x = 0;
	br.y = 0;
	br.height = 64;
	br.width = 64;
	spriteInfo = CreateSpriteInfo("../Textures/bombitem_anim.png",
		pos, size, &br);

	return new Bomb(spriteInfo, flames, p_tile, p_map, CreateSoundInfo("../Sounds/Click.wav",100), CreateSoundInfo("../Sounds/blast_2.wav",100));
}
Ejemplo n.º 9
0
TilePosition CoverMap::searchRefinerySpot()
{
	for(int i = 0 ; i < w ; i++)
	{
		for (int j = 0; j < h; j++)
		{
			if (cover_map[i][j] == GAS)
			{
				TilePosition cPos = TilePosition(i,j);

				bool found = false;
				vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents();
				for (int i = 0; i < (int)agents.size(); i++)
				{
					if (agents.at(i)->getUnitType().isRefinery())
				{
						double dist = agents.at(i)->getUnit()->getTilePosition().getDistance(cPos);
						TilePosition uPos = agents.at(i)->getUnit()->getTilePosition();
						if (dist <= 2)
				{
							found = true;
							break;
						}
					}
				}

				if (!found)
				{
					BaseAgent* agent = AgentManager::getInstance()->getClosestBase(cPos);
					if (agent != NULL)
					{
						TilePosition bPos = agent->getUnit()->getTilePosition();
						double dist = bPos.getDistance(cPos);

						if (dist < 15)
						{
							if (ExplorationManager::canReach(bPos, cPos))
							{
								return cPos;
							}			
						}
					}
				}
			}
		}
	}

	return TilePosition(-1, -1);
}
Ejemplo n.º 10
0
TilePosition CoverMap::findClosestGasWithoutRefinery(UnitType toBuild, TilePosition start)
{
	TilePosition bestSpot = TilePosition(-1,-1);
	double bestDist = -1;
	TilePosition home = Broodwar->self()->getStartLocation();
	Unit* worker = findWorker();

	for(int i = 0 ; i < w ; i++)
	{
		for (int j = 0; j < h; j++)
		{
			if (cover_map[i][j] == GAS)
			{
				TilePosition cPos = TilePosition(i,j);

				bool ok = true;
				vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents();
				for (int i = 0; i < (int)agents.size(); i++)
				{
					Unit* unit = agents.at(i)->getUnit();
					if (unit->getType().isRefinery())
					{
						double dist = unit->getTilePosition().getDistance(cPos);
						if (dist <= 2)
						{
							ok = false;
						}
					}
				}
				if (ok)
				{
					if (ExplorationManager::canReach(home, cPos))
					{
						BaseAgent* agent = AgentManager::getInstance()->getClosestBase(cPos);
						double dist = agent->getUnit()->getTilePosition().getDistance(cPos);
						if (bestDist == -1 || dist < bestDist)
						{
							bestDist = dist;
							bestSpot = cPos;
						}
					}
				}
			}
		}
	}

	return bestSpot;
}
Ejemplo n.º 11
0
TilePosition ExplorationManager::scanForVulnerableBase()
{
	TilePosition spot = TilePosition(-1, -1);
	for (int i = 0; i < (int)spottedBuildings.size(); i++)
	{
		if (spottedBuildings.at(i)->isActive())
		{
			SpottedObject* obj = spottedBuildings.at(i);
			if (obj->getType().isResourceDepot())
			{
				if (!isDetectorCovering(obj->getTilePosition()))
				{
					//Broodwar->printf("Found probable vulnerable base at (%d,%d)", obj->getTilePosition().x(), obj->getTilePosition().y());
					spot = obj->getTilePosition();
				}
			}
		}
	}

	if (spot.x() < 0)
	{
		//Broodwar->printf("Scan: No vulnerable base found");
	}

	return spot;
}
Ejemplo n.º 12
0
void PosterPrinter::bindCameraToImage( osg::Camera* camera, int row, int col )
{
    std::stringstream stream;
    stream << "image_" << row << "_" << col;
    
    osg::ref_ptr<osg::Image> image = new osg::Image;
    image->setName( stream.str() );
    image->allocateImage( (int)_tileSize.x(), (int)_tileSize.y(), 1, GL_RGBA, GL_UNSIGNED_BYTE );
    _images[TilePosition(row,col)] = image.get();
    
    // Calculate projection matrix offset of each tile
    osg::Matrix offsetMatrix =
        osg::Matrix::scale(_tileColumns, _tileRows, 1.0) *
        osg::Matrix::translate(_tileColumns-1-2*col, _tileRows-1-2*row, 0.0);
    camera->setViewMatrix( _currentViewMatrix );
    camera->setProjectionMatrix( _currentProjectionMatrix * offsetMatrix );
    
    // Check intersections between the image-tile box and the model
    osgUtil::IntersectionVisitor iv( _intersector.get() );
    iv.setReadCallback( g_pagedLoadingCallback.get() );
    _intersector->reset();
    camera->accept( iv );
    if ( _intersector->containsIntersections() )
    {
        // Apply a cull calback to every paged node obtained, to force the highest level displaying.
        // This will be done by the PosterVisitor, who already records all the paged nodes.
    }
    
    // Reattach cameras and new allocated images
    camera->setRenderingCache( NULL );  // FIXME: Uses for reattaching camera with image, maybe inefficient?
    camera->detach( osg::Camera::COLOR_BUFFER );
    camera->attach( osg::Camera::COLOR_BUFFER, image.get(), 0, 0 );
}
Ejemplo n.º 13
0
bool Commander::isOccupied(BWTA::Region* region)
{
	BWTA::Polygon p = region->getPolygon();
	vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents();
	for (int i = 0; i < (int)agents.size(); i++)
	{
		BaseAgent* agent = agents.at(i);
		if (agent->isAlive() && agent->getUnitType().isResourceDepot())
		{
			BWTA::Region* aRegion = getRegion(agents.at(i)->getUnit()->getTilePosition());
			Position c1 = region->getCenter();
			Position c2 = aRegion->getCenter();
			if (c2.x() == c1.x() && c2.y() == c1.y())
			{
				return true;
			}
		}
	}
	
	//Check expansion site
	TilePosition expansionSite = ExplorationManager::getInstance()->getExpansionSite();
	TilePosition center = TilePosition(region->getCenter());
	if (expansionSite.x() >= 0)
	{
		double dist = expansionSite.getDistance(center);
		if (dist <= 15)
		{
			return true;
		}
	}

	return false;
}
Ejemplo n.º 14
0
TilePosition CoverMap::findExpansionSite()
{
	UnitType baseType = Broodwar->self()->getRace().getCenter();
	double bestDist = 100000;
	TilePosition bestPos = TilePosition(-1, -1);
	
	//Iterate through all base locations
	for(set<BWTA::BaseLocation*>::const_iterator i=BWTA::getBaseLocations().begin(); i!= BWTA::getBaseLocations().end(); i++)
	{
		TilePosition pos = (*i)->getTilePosition();
		bool taken = false;
		
		//Check if own buildings are close
		vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents();
		int noBases = 0;
		for (int i = 0; i < (int)agents.size(); i++)
		{
			BaseAgent* agent = agents.at(i);
			if (agent->isAlive() && agent->getUnitType().isResourceDepot())
			{
				double dist = pos.getDistance(agent->getUnit()->getTilePosition());
				if (dist <= 12)
				{
					noBases++;
				}
			}
		}
		if (BuildPlanner::isZerg())
		{
			if (noBases >= 2) taken = true;
		}
		else
		{
			if (noBases >= 1) taken = true;
		}

		//Check if enemy buildings are close
		int eCnt = ExplorationManager::getInstance()->spottedBuildingsWithinRange(pos, 20);
		if (eCnt > 0)
		{
			taken = true;
		}

		//Not taken, calculate ground distance
		if (!taken)
		{
			if (ExplorationManager::canReach(Broodwar->self()->getStartLocation(), pos))
			{
				double dist = mapData.getDistance(Broodwar->self()->getStartLocation(), pos);
				if (dist <= bestDist)
				{
					bestDist = dist;
					bestPos = pos;
				}
			}
		}
	}

	return bestPos;
}
Ejemplo n.º 15
0
ZerglingAgent::ZerglingAgent(Unit mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "ZerglingAgent";
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 16
0
DoorEntity::DoorEntity(const TextureManager& textures, World* world)
	: Entity(world)
{
	mSprite.setTexture(textures.get(Textures::AutoDoors));
	setTilePosition(TilePosition(5,1));
	mSprite.setScale(world->getWorldScale());
	initalize();
}
Ejemplo n.º 17
0
DragoonAgent::DragoonAgent(Unit* mUnit) {
	unit = mUnit;
	unitID = unit->getID();
	//Broodwar->printf("DragoonAgent created (%s)", unit->getType().getName().c_str());
	lastFrame = 0;

	goal = TilePosition(-1, -1);
}
Ejemplo n.º 18
0
WraithAgent::WraithAgent(Unit mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "WraithAgent";
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 19
0
 //--------------------------------------------- GET INITIAL TILE POSITION ----------------------------------
 TilePosition UnitImpl::getInitialTilePosition() const
 {
   if (initialPosition == Positions::None)
   {
     return TilePositions::None;
   }
   return TilePosition(Position(initialPosition.x - initialType.tileWidth() * TILE_SIZE / 2,
                                initialPosition.y - initialType.tileHeight() * TILE_SIZE / 2));
 }
Ejemplo n.º 20
0
DevourerAgent::DevourerAgent(Unit* mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "DevourerAgent";
	
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 21
0
HighTemplarAgent::HighTemplarAgent(Unit* mUnit) {
	unit = mUnit;
	unitID = unit->getID();
	//Broodwar->printf("HighTemplarAgent created (%s)", unit->getType().getName().c_str());
	lastFrame = 0;

	goal = TilePosition(-1, -1);
	hasCastTransform = false;
}
Ejemplo n.º 22
0
ObserverAgent::ObserverAgent(Unit mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "ObserverAgent";
	
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 23
0
ReaverAgent::ReaverAgent(Unit* mUnit) {
    unit = mUnit;
    unitID = unit->getID();
    //Broodwar->printf("ReaverAgent created (%s)", unit->getType().getName().c_str());
    lastFrame = 0;

    goal = TilePosition(-1, -1);
    goalSet = false;
}
Ejemplo n.º 24
0
ScienceVesselAgent::ScienceVesselAgent(Unit* mUnit) {
	unit = mUnit;
	unitID = unit->getID();
	//Broodwar->printf("ScienceVesselAgent created (%s)", unit->getType().getName().c_str());
	lastFrame = 0;
	lastIrradiateFrame = 0;

	goal = TilePosition(-1, -1);
}
Ejemplo n.º 25
0
InfestedTerranAgent::InfestedTerranAgent(Unit* mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "InfestedTerranAgent";
	
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 26
0
BattlecruiserAgent::BattlecruiserAgent(Unit* mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "BattlecruiserAgent";
		
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 27
0
HighTemplarAgent::HighTemplarAgent(Unit* mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "HighTemplarAgent";
	
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 28
0
QueenAgent::QueenAgent(Unit* mUnit)
{
	unit = mUnit;
	type = unit->getType();
	unitID = unit->getID();
	agentType = "QueenAgent";
	
	goal = TilePosition(-1, -1);
}
Ejemplo n.º 29
0
TilePosition MapManager::findAttackPosition()
{
	MRegion* best = NULL;
	for (MRegion* cm : map)
	{
		if (cm->inf_en_buildings > 0)
		{
			if (best == NULL)
			{
				best = cm;
			}
			else
			{
				//Launch an attack at the enemy controlled region with the
				//lowest influence.
				if (cm->inf_en_buildings < best->inf_en_buildings)
				{
					best = cm;
				}
			}
		}
	}
	
	if (best != NULL)
	{
		return TilePosition(best->region->getCenter());
	}
	else
	{
		//No enemy building found. Move to starting positions.
		int longestVisitFrame = Broodwar->getFrameCount();
		TilePosition base = TilePosition(-1, -1);
		for (auto &a : bases)
		{
			if (a->frameVisited < longestVisitFrame)
			{
				longestVisitFrame = a->frameVisited;
				base = a->baseLocation;
			}
		}

		return base;
	}
}
Ejemplo n.º 30
0
VultureAgent::VultureAgent(Unit* mUnit)
{
    unit = mUnit;
    type = unit->getType();
    unitID = unit->getID();
    agentType = "VultureAgent";
    //Broodwar->printf("VultureAgent created (%s)", unit->getType().getName().c_str());

    goal = TilePosition(-1, -1);
}