• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TilePosition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TilePosition的典型用法代码示例。如果您正苦于以下问题:C++ TilePosition类的具体用法?C++ TilePosition怎么用?C++ TilePosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getRegion

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;
}
开发者ID:jieverson,项目名称:BTHAIMOD,代码行数:33,代码来源:Commander.cpp


示例2: moveToGoal

bool PFManager::moveToGoal(BaseAgent* agent,  TilePosition checkpoint, TilePosition goal)
{
	if (checkpoint.x() == -1 || goal.x() == -1) return false;
	Unit* unit = agent->getUnit();

	if (unit->isStartingAttack() || unit->isAttacking())
	{
		return false;
	}

	Position toReach = Position(checkpoint);
	double distToReach = toReach.getDistance(unit->getPosition());

	int engageDist = unit->getType().groundWeapon().maxRange();
	if (agent->isOfType(UnitTypes::Terran_Medic))
	{
		engageDist = 6 * 32;
	}
	if (engageDist <= 64)
	{
		engageDist = 64;
	}
	
	if (distToReach <= engageDist)
	{
		if (unit->isMoving()) unit->stop();
		return true;
	}
	
	//Move
	if (!unit->isMoving()) return unit->attack(toReach);
	else return true;
}
开发者ID:BuffBuff,项目名称:BTHAI_3.0,代码行数:33,代码来源:PFManager.cpp


示例3: TilePosition

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;
}
开发者ID:Malow,项目名称:Project-MalRilTil,代码行数:60,代码来源:CoverMap.cpp


示例4: findClosestMineral

Unit BuildingPlacer::findClosestMineral(TilePosition workerPos)
{
	Unit mineral = NULL;
	double bestDist = 10000;

	for(BaseLocation* base : getBaseLocations())
	{
		TilePosition pos = base->getTilePosition();
		double cDist = pos.getDistance(workerPos);
		if (cDist < bestDist)
		{
			//Find closest base
			BaseAgent* base = AgentManager::getInstance()->getClosestBase(pos);
			if (base != NULL)
			{
				double dist = pos.getDistance(base->getUnit()->getTilePosition());
				if (dist <= 12)
				{
					//We have a base near this base location
					//Check if we have minerals available
					Unit cMineral = hasMineralNear(pos);
					if (cMineral != NULL)
					{
						mineral = cMineral;
						bestDist = cDist;
					}
				}
			}
		}
	}

	//We have no base with minerals, do nothing
	return mineral;
}
开发者ID:jhagelback,项目名称:OpprimoBot,代码行数:34,代码来源:BuildingPlacer.cpp


示例5: targetPosition

void UnitClass::build(TilePosition target, BWAPI::UnitType type)
{
	if(exists())
	{
		const Position targetPosition(target.x()*32+type.tileWidth()*16, target.y()*32+type.tileHeight()*16);
		if(getDistance(type, targetPosition) > 48 || !MapHelper::isAllVisible(target, type))
		{
			move(targetPosition, 0);
			return;
		}

		if(mUnit->getOrder() == BWAPI::Orders::PlaceBuilding)
		{
			if(mUnit->getBuildType() == type && mUnit->getOrderTargetPosition() == targetPosition)
				return;
		}

		if(mUnit->getLastCommand().getType() == BWAPI::UnitCommandTypes::Build && mUnit->getLastCommand().getUnitType() == type && mUnit->getLastCommand().getTargetTilePosition() == target)
		{
			if(mLastOrderExecuteTime >= BWAPI::Broodwar->getFrameCount())
				return;
		}

		if(mUnit->build(target, type))
			mLastOrderExecuteTime = BWAPI::Broodwar->getFrameCount() + BWAPI::Broodwar->getRemainingLatencyFrames();
		else
			move(targetPosition, 0);
	}
}
开发者ID:SPQRBrutus,项目名称:skynetbot,代码行数:29,代码来源:Unit.cpp


示例6: removeMember

void Squad::removeMember(BaseAgent* agent)
{
	//Step 1. Remove the agent instance
	for (int i = 0; i < (int)agents.size(); i++)
	{
		if (agents.at(i)->getUnitID() == agent->getUnitID())
		{
			agents.at(i)->setSquadID(-1);
			agents.at(i)->assignToDefend();
			agents.erase(agents.begin() + i);
			break;
		}
	}

	//Step 2. Update the setup list
	for (int i = 0; i < (int)setup.size(); i++)
	{
		if (setup.at(i).equals(agent->getUnitType()))
		{
			setup.at(i).current--;
		}
	}

	//Step 3. If Explorer, set destination as explored (to avoid being killed at the same
	//place over and over again).
	if (isExplorer())
	{
		TilePosition goal = agent->getGoal();
		if (goal.x() >= 0)
		{
			ExplorationManager::Instance().setExplored(goal);
		}
	}
}
开发者ID:rarosu,项目名称:FnulAI,代码行数:34,代码来源:Squad.cpp


示例7: getNextExpansionLocation

BWAPI::TilePosition getNextExpansionLocation(TilePosition currentExpo)
{
	//remove the current expo from the list
	//loop through expos and find the nearest one
	std::set<BWTA::BaseLocation*> bases;

	for (auto &u : allBases)
	{
		//make sure we delete the current expansion
		if (u->getTilePosition() == currentExpo)
		{
			allBases.erase(u);
		}
	}
	BWTA::BaseLocation *ret = *allBases.begin();

	int minDistance = currentExpo.getApproxDistance(ret->getTilePosition());

	//make sure we dont accidently find current expansion
	for (auto &u : allBases)
	{
		int tempDistance = currentExpo.getApproxDistance(u->getTilePosition());
		if (tempDistance < minDistance && tempDistance > 10)
		{
			//found a closer base
			minDistance = tempDistance;
			ret = u;
		}
	}
	return ret->getTilePosition();
}
开发者ID:npham014,项目名称:SampleStarcraftAI,代码行数:31,代码来源:Util.cpp


示例8: isVisible

bool Squad::isVisible(TilePosition pos)
{
	if (!ExplorationManager::canReach(Broodwar->self()->getStartLocation(), pos))
	{
		return true;
	}

	if (Broodwar->isVisible(pos))
	{
		return true;
	}

	if (getCenter().getDistance(pos) <= 3)
	{
		return true;
	}

	for (int i = 0; i < (int)hasVisited.size(); i++)
	{
		TilePosition vPos = hasVisited.at(i);
		if (vPos.x() == pos.x() && vPos.y() == pos.y())
		{
			return true;
		}
	}

	return false;
}
开发者ID:rarosu,项目名称:FnulAI,代码行数:28,代码来源:Squad.cpp


示例9: findClosestMineral

Unit* CoverMap::findClosestMineral(TilePosition workerPos)
{
	Unit* mineral = NULL;
	double bestDist = 10000;

	for(set<BWTA::BaseLocation*>::const_iterator i=BWTA::getBaseLocations().begin(); i!= BWTA::getBaseLocations().end(); i++)
	{
		TilePosition pos = (*i)->getTilePosition();
		double cDist = pos.getDistance(workerPos);
		if (cDist < bestDist)
		{
			//Find closest base
			BaseAgent* base = AgentManager::getInstance()->getClosestBase(pos);
			double dist = pos.getDistance(base->getUnit()->getTilePosition());
			if (dist <= 12)
			{
				//We have a base near this base location
				//Check if we have minerals available
				Unit* cMineral = hasMineralNear(pos);
				if (cMineral != NULL)
				{
					mineral = cMineral;
					bestDist = cDist;
				}
			}
		}
	}

	//We have no base with minerals, do nothing
	return mineral;
}
开发者ID:Malow,项目名称:Project-MalRilTil,代码行数:31,代码来源:CoverMap.cpp


示例10: checkMinerals

/*
if the mineral fields at our base are getting low then construct a new base
*/
void ProductionManager::checkMinerals()
{
	if(!expansionQueued)
	{
		Unit* closestMineral = NULL;
		TilePosition home;

		//find main
		for(std::set<Unit*>::const_iterator i=Broodwar->self()->getUnits().begin();i!=Broodwar->self()->getUnits().end();i++)
		{
			if ((*i)->getType().isResourceDepot())
			{
				home = (*i)->getTilePosition();
				for(std::set<BWAPI::Unit*>::iterator m = Broodwar->getMinerals().begin(); m != Broodwar->getMinerals().end(); m++)
				{
					if (closestMineral==NULL || home.getDistance((*m)->getTilePosition()) < home.getDistance(closestMineral->getTilePosition()))
					closestMineral=*m;
				}
				if (closestMineral!=NULL)
				{
					if(closestMineral->getResources() < 150)
					{
						production.queueAsHighestPriority(MetaType(Broodwar->self()->getRace().getCenter()), true);
						expansionQueued = true;
					}
				}
			}
		}
	}
}
开发者ID:iarfmoose,项目名称:MooseBot,代码行数:33,代码来源:ProductionManager.cpp


示例11: TilePosition

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;
}
开发者ID:jieverson,项目名称:BTHAIMOD,代码行数:26,代码来源:ExplorationManager.cpp


示例12: getTilePosition

void UnitClass::drawUnitTilePosition()
{
	TilePosition tile = getTilePosition();
	BWAPI::UnitType type = getType();
	Player player = getPlayer();

	BWAPI::Broodwar->drawBox(BWAPI::CoordinateType::Map, tile.x()*32, tile.y()*32, (tile.x()+type.tileWidth())*32, (tile.y()+type.tileHeight())*32, player->getColor());
}
开发者ID:SPQRBrutus,项目名称:skynetbot,代码行数:8,代码来源:Unit.cpp


示例13: positionFree

bool CoverMap::positionFree(TilePosition pos)
{
	if (cover_map[pos.x()][pos.y()] == BUILDABLE)
	{
		return true;
	}
	return false;
}
开发者ID:Malow,项目名称:Project-MalRilTil,代码行数:8,代码来源:CoverMap.cpp


示例14: blockPosition

void CoverMap::blockPosition(TilePosition buildSpot)
{
	if (buildSpot.x() == -1)
	{
		//Error check
		return;
	}
	cover_map[buildSpot.x()][buildSpot.y()] = BLOCKED;
}
开发者ID:Malow,项目名称:Project-MalRilTil,代码行数:9,代码来源:CoverMap.cpp


示例15: matches

bool PathObj::matches(TilePosition cStart, TilePosition cEnd)
{
	//Check if end almost matches
	double dist = cEnd.getDistance(end);
	if (dist > 3) return false;
	
	//Check if start almost matches.
	dist = cStart.getDistance(start);
	if (dist > 5) return false;
	return true;
}
开发者ID:jhagelback,项目名称:OpprimoBot,代码行数:11,代码来源:PathObj.cpp


示例16: defend

void Squad::defend(TilePosition mGoal)
{
	if (mGoal.x() == -1 || mGoal.y() == -1) return;

	if (currentState != STATE_DEFEND)
	{
		if (currentState == STATE_ASSIST && !isUnderAttack())
		{
			currentState = STATE_DEFEND;
		}
	}
	setGoal(mGoal);
}
开发者ID:rarosu,项目名称:FnulAI,代码行数:13,代码来源:Squad.cpp


示例17: findChokePoint

void Commander::updateGoals()
{
	TilePosition defSpot = findChokePoint();
	
	if (defSpot.x() != -1)
	{
		for (int i = 0; i < (int)squads.size(); i++)
		{
			Squad* sq = squads.at(i);
			squads.at(i)->defend(defSpot);
		}
	}
}
开发者ID:jieverson,项目名称:BTHAIMOD,代码行数:13,代码来源:Commander.cpp


示例18: isThisGoal

bool Squad::isThisGoal(TilePosition mGoal)
{
	int xDiff = goal.x() - mGoal.x();
	if (xDiff < 0) xDiff *= -1;
	int yDiff = goal.y() - mGoal.y();
	if (yDiff < 0) yDiff *= -1;

	//Broodwar->printf("SQ %d: (%d,%d) = (%d,%d)", id, goal.x(), goal.y(), mGoal.x(), mGoal.y());
	if (xDiff <= 2 && yDiff <= 2)
	{
		return true;
	}
	return false;
}
开发者ID:rarosu,项目名称:FnulAI,代码行数:14,代码来源:Squad.cpp


示例19: getChokepointPrio

double Commander::getChokepointPrio(TilePosition center)
{
	TilePosition ePos = ExplorationManager::getInstance()->getClosestSpottedBuilding(center);

	if (ePos.x() >= 0)
	{
		double dist = ePos.getDistance(center);
		return 1000 - dist;
	}
	else
	{
		double dist = Broodwar->self()->getStartLocation().getDistance(center);
		return dist;
	}
}
开发者ID:jieverson,项目名称:BTHAIMOD,代码行数:15,代码来源:Commander.cpp


示例20: canBuildAt

bool CoverMap::canBuildAt(UnitType toBuild, TilePosition pos)
{
	int maxW = w - toBuild.tileWidth() - 1;
	int maxH = h - toBuild.tileHeight() - 1;

	//Out of bounds check
	if (pos.x() >= 0 && pos.x() < maxW && pos.y() >= 0 && pos.y() < maxH)
	{
		if (canBuild(toBuild, pos))
		{
			return true;
		}
	}
	return false;
}
开发者ID:Malow,项目名称:Project-MalRilTil,代码行数:15,代码来源:CoverMap.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TilePtr类代码示例发布时间:2022-05-31
下一篇:
C++ TilePos类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap