本文整理汇总了C++中boost::thread_specific_ptr::isInTheMap方法的典型用法代码示例。如果您正苦于以下问题:C++ thread_specific_ptr::isInTheMap方法的具体用法?C++ thread_specific_ptr::isInTheMap怎么用?C++ thread_specific_ptr::isInTheMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::thread_specific_ptr
的用法示例。
在下文中一共展示了thread_specific_ptr::isInTheMap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAllPossibleSubgoals
TGoalVec VisitTile::getAllPossibleSubgoals()
{
assert(cb->isInTheMap(tile));
TGoalVec ret;
if (!cb->isVisible(tile))
ret.push_back (sptr(Goals::Explore())); //what sense does it make?
else
{
std::vector<const CGHeroInstance *> heroes;
if (hero)
heroes.push_back(hero.h); //use assigned hero if any
else
heroes = cb->getHeroesInfo(); //use most convenient hero
for (auto h : heroes)
{
if (ai->isAccessibleForHero(tile, h))
ret.push_back (sptr(Goals::VisitTile(tile).sethero(h)));
}
if (ai->canRecruitAnyHero())
ret.push_back (sptr(Goals::RecruitHero()));
}
if (ret.empty())
{
auto obj = frontOrNull(cb->getVisitableObjs(tile));
if (obj && obj->ID == Obj::HERO && obj->tempOwner == ai->playerID) //our own hero stands on that tile
ret.push_back (sptr(Goals::VisitTile(tile).sethero(dynamic_cast<const CGHeroInstance *>(obj)).setisElementar(true)));
else
ret.push_back (sptr(Goals::ClearWayTo(tile)));
}
//important - at least one sub-goal must handle case which is impossible to fulfill (unreachable tile)
return ret;
}
示例2: foreach_neighbour
void foreach_neighbour(const int3 &pos, std::function<void(const int3& pos)> foo)
{
for(const int3 &dir : dirs)
{
const int3 n = pos + dir;
if(cb->isInTheMap(n))
foo(pos+dir);
}
}
示例3: whatToDoToAchieve
TSubgoal ClearWayTo::whatToDoToAchieve()
{
assert(cb->isInTheMap(tile)); //set tile
if(!cb->isVisible(tile))
{
logAi->errorStream() << "Clear way should be used with visible tiles!";
return sptr (Goals::Explore());
}
return (fh->chooseSolution(getAllPossibleSubgoals()));
}
示例4: howManyTilesWillBeDiscovered
int howManyTilesWillBeDiscovered(const int3 &pos, int radious)
{ //TODO: do not explore dead-end boundaries
int ret = 0;
for(int x = pos.x - radious; x <= pos.x + radious; x++)
{
for(int y = pos.y - radious; y <= pos.y + radious; y++)
{
int3 npos = int3(x,y,pos.z);
if(cb->isInTheMap(npos) && pos.dist2d(npos) - 0.5 < radious && !cb->isVisible(npos))
{
if (!boundaryBetweenTwoPoints (pos, npos))
ret++;
}
}
}
return ret;
}
示例5: getAllPossibleSubgoals
TGoalVec VisitTile::getAllPossibleSubgoals()
{
assert(cb->isInTheMap(tile));
TGoalVec ret;
if (!cb->isVisible(tile))
ret.push_back (sptr(Goals::Explore())); //what sense does it make?
else
{
std::vector<const CGHeroInstance *> heroes;
if (hero)
heroes.push_back(hero.h); //use assigned hero if any
else
heroes = cb->getHeroesInfo(); //use most convenient hero
for (auto h : heroes)
{
if (ai->isAccessibleForHero(tile, h))
ret.push_back (sptr(Goals::VisitTile(tile).sethero(h)));
}
if (ai->canRecruitAnyHero())
ret.push_back (sptr(Goals::RecruitHero()));
}
if(ret.empty())
{
auto obj = vstd::frontOrNull(cb->getVisitableObjs(tile));
if(obj && obj->ID == Obj::HERO && obj->tempOwner == ai->playerID) //our own hero stands on that tile
{
if (hero.get(true) && hero->id == obj->id) //if it's assigned hero, visit tile. If it's different hero, we can't visit tile now
ret.push_back(sptr(Goals::VisitTile(tile).sethero(dynamic_cast<const CGHeroInstance *>(obj)).setisElementar(true)));
else
throw cannotFulfillGoalException("Tile is already occupied by another hero "); //FIXME: we should give up this tile earlier
}
else
ret.push_back (sptr(Goals::ClearWayTo(tile)));
}
//important - at least one sub-goal must handle case which is impossible to fulfill (unreachable tile)
return ret;
}