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


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

本文整理汇总了C++中bwta::BaseLocation::getMinerals方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseLocation::getMinerals方法的具体用法?C++ BaseLocation::getMinerals怎么用?C++ BaseLocation::getMinerals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bwta::BaseLocation的用法示例。


在下文中一共展示了BaseLocation::getMinerals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: check

void ProbeUnit::check()
{
	if (backUpMineral == NULL || !backUpMineral->exists())
	{
		if (Broodwar->getFrameCount() < 10*24*60)
		{
			BWTA::BaseLocation* b = BWTA::getStartLocation(Broodwar->self());
			if (b != NULL && !b->getMinerals().empty())
				backUpMineral = *(b->getMinerals().begin());
			if (backUpMineral == NULL || !backUpMineral->exists())
				backUpMineral = NULL;
		}
	}
}
开发者ID:AIUR-group,项目名称:BroodwarBotQ,代码行数:14,代码来源:ProbeUnit.cpp

示例2: getSunkenPosition

// Get a sunken position depending on whether or not we have an expansion.
BWAPI::TilePosition BuildingManager::getSunkenPosition()
{

	BWAPI::UnitType sunk = BWAPI::UnitTypes::Zerg_Creep_Colony;
	// Always make sunkens at natural expansion if you can.
	if (createdHatcheriesSet.size() >= 1)
	{
		BWAPI::TilePosition hatchPosition = createdHatcheriesVector[0];
		BWAPI::Unit pExpansion = BWAPI::Broodwar->getClosestUnit(BWAPI::Position(hatchPosition), BWAPI::Filter::IsResourceDepot);
		BWAPI::Unitset myUnits = pExpansion->getUnitsInRadius(200);
		BWAPI::UnitType larva = BWAPI::UnitTypes::Zerg_Larva;
		BWAPI::UnitType egg = BWAPI::UnitTypes::Zerg_Egg;

		std::set<BWAPI::TilePosition> stuffBlocking;
		for (BWAPI::Unit p : myUnits)
		{
			if (p->getType() == larva || p->getType() == egg)
			{
				stuffBlocking.insert(p->getTilePosition());
			}
		}

		while (buildableSunkenTilePositions.size() >= 1)
		{
			std::set<BWAPI::TilePosition>::iterator it = buildableSunkenTilePositions.begin();


			BWAPI::TilePosition mySunkPosition = *it;
			Building z(sunk, mySunkPosition);

			if (!isCreepStarted())
			{
				if (BWAPI::Broodwar->hasCreep(mySunkPosition) && createdBuilding.find(mySunkPosition) == createdBuilding.end() && stuffBlocking.find(mySunkPosition) == stuffBlocking.end())
				{
					return *it;
				}
				else
				{
					buildableSunkenTilePositions.erase(*it);
				}
			}

			else
			{
				if (BWAPI::Broodwar->hasCreep(mySunkPosition) && BuildingPlacer::Instance().canBuildHere(mySunkPosition, z) && createdBuilding.find(mySunkPosition) == createdBuilding.end() && stuffBlocking.find(mySunkPosition) == stuffBlocking.end())
				{
					return *it;
				}
				else
				{
					buildableSunkenTilePositions.erase(*it);
				}

			}


		
		}


		//BWAPI::Position hatchPositionBWP = BWAPI::Position(hatchPosition);
		BWAPI::TilePosition sunkPosition;

		const std::set<BWTA::BaseLocation*, std::less<BWTA::BaseLocation*>> locations = BWTA::getBaseLocations();
		BWTA::BaseLocation *myLocation;

		for (BWTA::BaseLocation *p : locations) {
			BWAPI::TilePosition z = p->getTilePosition();
			if (z == hatchPosition){
				// This is the BWTA::Location of the first hatchery.
				myLocation = p;

			}
		}
		// Get the set of mineral patches closest to BWTA::Location of the hatchery(it will return like 8 mineral patches usually in the set)
		const BWAPI::Unitset mineralSet = myLocation->getMinerals();
		//const std::set<BWAPI::Unit*> mineralSet = myLocation->getMinerals();

		int counter3 = 0;
		int theX = 0;
		int theY = 0;
		for (BWAPI::Unit p : mineralSet)
		{
			// Calculate the difference between LeftMostMineralPatch.x - ExpansionHatchery.x and store it in theX
			theX = p->getTilePosition().x - hatchPosition.x;
			// Calculate the difference between LeftMostMineralPatch.y - ExpansionHatchery.y and store it in theY
			theY = p->getTilePosition().y - hatchPosition.y;
			break;
		}

		int gasX = 0;
		int gasY = 0;
		int counter4 = 0;
		//Get all geysers near the expansion -- it should only return 1 for every map we play..
		const BWAPI::Unitset gasSet = myLocation->getGeysers();
		for (BWAPI::Unit p : gasSet)
		{
			// Calculate the difference between Geyser.x- ExpansionHatchery.x and store it in gasX
			gasX = p->getTilePosition().x - hatchPosition.x;
//.........这里部分代码省略.........
开发者ID:0x4849,项目名称:c350,代码行数:101,代码来源:BuildingManagergggg.cpp

示例3: checkForCompletedBuildings


//.........这里部分代码省略.........


			// remove this unit from the under construction vector
			toRemove.push_back(b);
		}
		else
		{
			if (b.type == 131 && b.buildingUnit->getHitPoints() >= 1050 &&  !transferredDrones)
			{


				//BWAPI::Broodwar->printf("Send Drone");
				//BWAPI::Unitset candidateProducers;
				BWAPI::UnitType sunk = BWAPI::UnitTypes::Zerg_Creep_Colony;
				Building z(sunk, createdHatcheriesVector[0]);
				//BWAPI::Unit workerToAssign = WorkerManager::Instance().getMoveWorker(BWAPI::Position(createdHatcheriesVector[0]));
				//BWAPI::Unit workerToAssign2 = WorkerManager::Instance().getMoveWorker(BWAPI::Position(createdHatcheriesVector[0]));
				//WorkerManager::Instance().setMoveWorker(0, 0, BWAPI::Position(createdHatcheriesVector[0]));
				//WorkerManager::Instance().setMoveWorker(0, 0, BWAPI::Position(createdHatcheriesVector[0]));
				//_reservedMinerals += 75;


				BWAPI::Unit workerToAssign = WorkerManager::Instance().getBuilder(z);
				BWAPI::Unit workerToAssign2 = WorkerManager::Instance().getBuilder(z);

				//WorkerData m;
				//m.setWorkerJob(workerToAssign, WorkerData::Minerals, b.type);
				/*
				for (BWAPI::Unit p : BWAPI::Broodwar->self()->getUnits())
				{
				WorkerData k;

				WorkerData::WorkerJob j = k.getWorkerJob(p);
				if (p->getType().isWorker() && j != WorkerData::Scout)
				{
				*/

				const std::set<BWTA::BaseLocation*, std::less<BWTA::BaseLocation*>> locations = BWTA::getBaseLocations();
				BWTA::BaseLocation *myLocation;

				for (BWTA::BaseLocation *p : locations) {
					BWAPI::TilePosition z = p->getTilePosition();
					if (z == createdHatcheriesVector[0]){
						// This is the BWTA::Location of the first hatchery.
						myLocation = p;
					}
				}
				// Get the set of mineral patches closest to BWTA::Location of the hatchery(it will return like 8 mineral patches usually in the set)
				const BWAPI::Unitset mineralSet = myLocation->getMinerals();

				BWAPI::Unit myMineral;
				for (BWAPI::Unit p : mineralSet)
				{
					myMineral = p;
					// Calculate the difference between LeftMostMineralPatch.x - ExpansionHatchery.x and store it in theX
					//theX = p->getTilePosition().x - hatchPosition.x;
					// Calculate the difference between LeftMostMineralPatch.y - ExpansionHatchery.y and store it in theY
					//theY = p->getTilePosition().y - hatchPosition.y;
					break;
				}



				workerToAssign->gather(myMineral);
				workerToAssign2->gather(myMineral);
				sunkenUnit = workerToAssign;
				sunkenUnit2 = workerToAssign2;
				//sunkenID = workerToAssign->getID();


			
				transferredDrones = true;

			}

			if (b.type == 131 && b.buildingUnit->getHitPoints() >= 1225 && !sentFirstDroneForSunken)
			{
				MetaType type(BWAPI::UnitTypes::Zerg_Creep_Colony);
				ProductionManager::Instance()._queue.queueAsHighestPriority(type, true);
						//sunkenID2 = workerToAssign2->getID();
						//BWAPI::TilePosition tempPosition;
						//tempPosition.x = b.finalPosition.x+4;
						//tempPosition.y = b.finalPosition.y+4;
						//Micro::SmartMove(p, BWAPI::Position(tempPosition));
						//Micro::SmartMove(p, BWAPI::Position(tempPosition));
						//p->move(BWAPI::Position(tempPosition));
						//p->move(BWAPI::Position(tempPosition));
						//break;
						//candidateProducers.insert(p);
					
				//MetaType type(BWAPI::UnitTypes::Zerg_Creep_Colony);
				//ProductionManager::Instance()._queue.queueAsHighestPriority(type, true);
				sentFirstDroneForSunken = true;
			}

		}
	}

	removeBuildings(toRemove);
}
开发者ID:0x4849,项目名称:c350,代码行数:101,代码来源:BuildingManagergggg.cpp

示例4: checkForCompletedBuildings


//.........这里部分代码省略.........
							//tempPosition.x = b.finalPosition.x + 3;
							//tempPosition.y = b.finalPosition.y + 3;
					
							/*
							BWAPI::TilePosition sunkPos = getSunkenPosition();


							createdSunkenSet.insert(sunkPos);
							createdSunkenVector.push_back(sunkPos);
							createdBuilding.insert(sunkPos);
							p->build(BWAPI::UnitTypes::Zerg_Hatchery, sunkPos);

							madeFirstSunken = true;


							BWAPI::TilePosition sunkPos2 = getSunkenPosition();


							createdSunkenSet.insert(sunkPos2);
							createdSunkenVector.push_back(sunkPos2);
							createdBuilding.insert(sunkPos2);
							p->build(BWAPI::UnitTypes::Zerg_Hatchery, sunkPos2);
							//b.builderUnit->build(b.type, b.finalPosition);
							
							break;
							
							//candidateProducers.insert(p);
						}
					}
				}
			*/

			}
			// if we are terran, give the worker back to worker manager
			if (BWAPI::Broodwar->self()->getRace() == BWAPI::Races::Terran)
			{
				if (b.isGasSteal)
				{
					ScoutManager::Instance().setWorkerScout(b.builderUnit);
				}
				// otherwise tell the worker manager we're finished with this unit
				else
				{
					WorkerManager::Instance().finishedWithWorker(b.builderUnit);
				}
			}



			// remove this unit from the under construction vector
			toRemove.push_back(b);
		}
		else
		{
			
			if (b.type == 131 && b.buildingUnit->getHitPoints() >= 1050 && !sentFirstDroneForSunken)
			{

				BWAPI::UnitType sunk = BWAPI::UnitTypes::Zerg_Creep_Colony;
				Building z(sunk, createdHatcheriesVector[0]);
				BWAPI::Unit workerToAssign = WorkerManager::Instance().getBuilder(z);
				BWAPI::Unit workerToAssign2 = WorkerManager::Instance().getBuilder(z);

				const std::set<BWTA::BaseLocation*, std::less<BWTA::BaseLocation*>> locations = BWTA::getBaseLocations();
				BWTA::BaseLocation *myLocation;

				for (BWTA::BaseLocation *p : locations) {
					BWAPI::TilePosition z = p->getTilePosition();
					if (z == createdHatcheriesVector[0]){
						// This is the BWTA::Location of the first hatchery.
						myLocation = p;
					}
				}
				// Get the set of mineral patches closest to BWTA::Location of the hatchery(it will return like 8 mineral patches usually in the set)
				const BWAPI::Unitset mineralSet = myLocation->getMinerals();

				BWAPI::Unit myMineral;
				for (BWAPI::Unit p : mineralSet)
				{
					myMineral = p;
					break;
				}



				workerToAssign->gather(myMineral);
				workerToAssign2->gather(myMineral);
				sunkenUnit = workerToAssign;
				sunkenUnit2 = workerToAssign2;

				sentFirstDroneForSunken = true;
				
			}
			int x = 0;
			
		}
	}

	removeBuildings(toRemove);
}
开发者ID:0x4849,项目名称:c350,代码行数:101,代码来源:BuildingManager.cpp


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