本文整理汇总了C++中bwta::BaseLocation::getGroundDistance方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseLocation::getGroundDistance方法的具体用法?C++ BaseLocation::getGroundDistance怎么用?C++ BaseLocation::getGroundDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwta::BaseLocation
的用法示例。
在下文中一共展示了BaseLocation::getGroundDistance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expand
BWTA::BaseLocation* BaseManager::expand(int priority)
{
BWTA::BaseLocation* location = NULL;
BWTA::BaseLocation* locationWithoutGas = NULL;
double minDist=-1;
BWTA::BaseLocation* home = BWTA::getStartLocation(BWAPI::Broodwar->self());
std::set<BWTA::BaseLocation*>::const_iterator i;
for(i = BWTA::getBaseLocations().begin(); i != BWTA::getBaseLocations().end(); i++)
{
BWTA::BaseLocation *baseLocation = (*i);
if (baseLocation->isIsland())
{
continue;
}
double dist = home->getGroundDistance(baseLocation);
if (dist > 0 && getBase(baseLocation) == NULL)
{
if (minDist == -1 || dist < minDist)
{
if (baseLocation->isMineralOnly())
{
locationWithoutGas = baseLocation;
}
else
{
location = baseLocation;
minDist = dist;
}
}
}
}
if (location == NULL && locationWithoutGas != NULL)
{
BWAPI::Broodwar->printf("Expanding to location without gas.");
location = locationWithoutGas;
}
return expand(location, priority);
}
示例2: onStart
void BasicAIModule::onStart()
{
Broodwar->enableFlag( Flag::UserInput );
BWTA::readMap();
BWTA::analyze();
BWSAL::resetLog();
m_informationManager = InformationManager::create();
m_borderManager = BorderManager::create( m_informationManager );
m_baseManager = BaseManager::create( m_borderManager );
m_buildingPlacer = new BFSBuildingPlacer();
m_reservedMap = ReservedMap::create();
m_unitArbitrator = new UnitArbitrator();
m_unitGroupManager = UnitGroupManager::create();
m_buildUnitManager = BuildUnitManager::create();
m_buildEventTimeline = BuildEventTimeline::create( m_buildUnitManager );
m_taskScheduler = TaskScheduler::create( m_buildEventTimeline, m_buildUnitManager );
m_taskExecutor = TaskExecutor::create( m_unitArbitrator, m_buildEventTimeline, m_reservedMap, m_buildingPlacer );
m_workerManager = WorkerManager::create( m_unitArbitrator, m_baseManager );
m_scoutManager = ScoutManager::create( m_unitArbitrator, m_informationManager );
m_defenseManager = DefenseManager::create( m_unitArbitrator, m_borderManager );
m_buildOrderManager = BuildOrderManager::create( m_taskScheduler, m_taskExecutor, m_buildUnitManager );
m_supplyManager = SupplyManager::create( m_buildOrderManager, m_taskScheduler );
m_enhancedUI = new EnhancedUI();
m_buildEventTimeline->initialize();
m_scoutManager->initialize();
m_modules.push_back( m_informationManager );
m_modules.push_back( m_borderManager );
m_modules.push_back( m_baseManager );
m_modules.push_back( m_buildEventTimeline );
m_modules.push_back( m_reservedMap );
m_modules.push_back( m_unitGroupManager );
m_modules.push_back( m_buildUnitManager );
m_modules.push_back( m_taskScheduler );
m_modules.push_back( m_taskExecutor );
m_modules.push_back( m_workerManager );
m_modules.push_back( m_scoutManager );
m_modules.push_back( m_defenseManager );
BWAPI::Race race = Broodwar->self()->getRace();
BWAPI::Race enemyRace = Broodwar->enemy()->getRace();
double minDist;
BWTA::BaseLocation* natural = NULL;
BWTA::BaseLocation* home = BWTA::getStartLocation( Broodwar->self() );
foreach( BWTA::BaseLocation* bl, BWTA::getBaseLocations() )
{
if ( bl != home )
{
double dist = home->getGroundDistance( bl );
if ( dist > 0 )
{
if ( natural == NULL || dist < minDist)
{
minDist = dist;
natural = bl;
}
}
}
}
int buildID = 1;
if ( race == Races::Zerg )
{
// Send an overlord out if Zerg
m_scoutManager->setScoutCount( 1 );
if (buildID == 1)
{
//morph 5 lurkers (tests dependency resolver, task scheduler)
m_buildOrderManager->build( 8, UnitTypes::Zerg_Drone, 90 );
m_buildOrderManager->buildAdditional( 1, UnitTypes::Zerg_Overlord, 85 );
m_buildOrderManager->build( 12, UnitTypes::Zerg_Drone, 84 );
m_buildOrderManager->buildAdditional( 1, UnitTypes::Zerg_Lair, 82);
m_buildOrderManager->buildAdditional( 5, UnitTypes::Zerg_Lurker, 80);
m_buildOrderManager->build( 12, UnitTypes::Zerg_Drone, 30 );
}
else if (buildID >= 2)
{
//12 pool 6 lings (tests larva task scheduler)
m_buildOrderManager->build( 8, UnitTypes::Zerg_Drone, 90 );
m_buildOrderManager->buildAdditional( 1, UnitTypes::Zerg_Overlord, 85 );
m_buildOrderManager->build( 12, UnitTypes::Zerg_Drone, 84 );
m_buildOrderManager->buildAdditional( 1, UnitTypes::Zerg_Spawning_Pool, 70 );
m_buildOrderManager->buildAdditional( 3, UnitTypes::Zerg_Zergling, 65 );
m_buildOrderManager->build( 40, UnitTypes::Zerg_Drone, 62 );
}
}
else if ( race == Races::Terran )
{
if (buildID == 1)
{
//build 3 comsat stations (tests dependency resolver)
m_buildOrderManager->build(9,UnitTypes::Terran_SCV,90);
m_buildOrderManager->build(1,UnitTypes::Terran_Supply_Depot,85);
m_buildOrderManager->build(20,UnitTypes::Terran_SCV,80);
m_buildOrderManager->buildAdditional(3,UnitTypes::Terran_Comsat_Station,60);
}
else if (buildID == 2)
{
//.........这里部分代码省略.........