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


C++ thread_specific_ptr::getCachedSectorMap方法代码示例

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


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

示例1: getAllPossibleSubgoals

TGoalVec Conquer::getAllPossibleSubgoals()
{
	TGoalVec ret;

	auto conquerable = [](const CGObjectInstance * obj) -> bool
	{
		if (cb->getPlayerRelations(ai->playerID, obj->tempOwner) == PlayerRelations::ENEMIES)
		{
			switch (obj->ID.num)
			{
				case Obj::TOWN:
				case Obj::HERO:
				case Obj::CREATURE_GENERATOR1:
				case Obj::MINE: //TODO: check ai->knownSubterraneanGates
					return true;
			}
		}
		return false;
	};

	std::vector<const CGObjectInstance *> objs;
	for (auto obj : ai->visitableObjs)
	{
		if (conquerable(obj))
			objs.push_back (obj);
	}

	for (auto h : cb->getHeroesInfo())
	{
		auto sm = ai->getCachedSectorMap(h);
		std::vector<const CGObjectInstance *> ourObjs(objs); //copy common objects

		for (auto obj : ai->reservedHeroesMap[h]) //add objects reserved by this hero
		{
			if (conquerable(obj))
				ourObjs.push_back(obj);
		}
		for (auto obj : ourObjs)
		{
			int3 dest = obj->visitablePos();
			auto t = sm->firstTileToGet(h, dest); //we assume that no more than one tile on the way is guarded
			if (t.valid()) //we know any path at all
			{
				if (ai->isTileNotReserved(h, t)) //no other hero wants to conquer that tile
				{
					if (isSafeToVisit(h, dest))
					{
						if (dest != t) //there is something blocking our way
							ret.push_back(sptr(Goals::ClearWayTo(dest, h).setisAbstract(true)));
						else
						{
							if (obj->ID.num == Obj::HERO) //enemy hero may move to other position
								ret.push_back(sptr(Goals::VisitHero(obj->id.getNum()).sethero(h).setisAbstract(true)));
							else //just visit that tile
								ret.push_back(sptr(Goals::VisitTile(dest).sethero(h).setisAbstract(true)));
						}
					}
					else //we need to get army in order to conquer that place
						ret.push_back(sptr(Goals::GatherArmy(evaluateDanger(dest, h) * SAFE_ATTACK_CONSTANT).sethero(h).setisAbstract(true)));
				}
			}
		}
	}
	if (!objs.empty() && ai->canRecruitAnyHero()) //probably no point to recruit hero if we see no objects to capture
		ret.push_back (sptr(Goals::RecruitHero()));

	if (ret.empty())
		ret.push_back (sptr(Goals::Explore())); //we need to find an enemy
	return ret;
}
开发者ID:,项目名称:,代码行数:70,代码来源:


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