当前位置: 首页>>代码示例>>C++>>正文


C++ BaseLocation::getGroundDistance方法代码示例

本文整理汇总了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);
}
开发者ID:albertouri,项目名称:dementor-bot,代码行数:45,代码来源:BaseManager.cpp

示例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)
    {
//.........这里部分代码省略.........
开发者ID:Insomniumm,项目名称:bwsal,代码行数:101,代码来源:BasicAIModule.cpp


注:本文中的bwta::BaseLocation::getGroundDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。