本文整理汇总了C++中Path::GetStart方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::GetStart方法的具体用法?C++ Path::GetStart怎么用?C++ Path::GetStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::GetStart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeMoves
//makes the bots moves for the turn
void AntWar::MakeMoves()
{
NavDijkstra m_oNavDijkstra(m_oWorld.GetGrid());
NavAStar m_oNavAStar(m_oWorld.GetGrid());
int iExplMin = 5;
float fExplCoeff = 0.1f;
int iAntCount = m_oWorld.GetAntCount();
int iExpl = max(min(iExplMin, iAntCount), (int)(iAntCount * fExplCoeff));
int iProtect = 0;//max<int>(0, min<int>(m_oWorld.GetMinDistCount(), (int)m_oWorld.GetAntCount() - iExpl));
int iGuard = max<int>(0, iAntCount - (iExpl + iProtect));
DistAntMap::const_reverse_iterator begin = m_oWorld.GetAntByDist().rbegin();
DistAntMap::const_reverse_iterator end = m_oWorld.GetAntByDist().rend();
DistAntMap::const_reverse_iterator it;
// Default Explore / Guard / Protect
int i;
for (i=0, it=begin ; it != end ; ++it, ++i)
{
Ant* pAnt = it->second;
if (pAnt->GetPlayer() > 0)
continue;
Vector2 loc = pAnt->GetLocation();
if (i<iExpl)
pAnt->SetRole(Explore);
if (i>=iExpl && i<iExpl+iGuard)
pAnt->SetRole(Guard);
if (i>=iExpl+iGuard)
pAnt->SetRole(Protect);
}
// Attack
for (uint i=0 ; i<m_oWorld.GetAntCount() ; ++i)
{
Ant& oAnt = m_oWorld.GetAnt(i);
if (oAnt.GetPlayer() == 0)
oAnt.TestAnts(m_oWorld);
}
for (uint i=0 ; i<m_oWorld.GetAntCount() ; ++i)
{
Ant& oAnt = m_oWorld.GetAnt(i);
if (oAnt.GetPlayer() == 0)
oAnt.ReachAllies(m_oWorld);
}
// Loot
vector<Vector2> aLootLoc;
aLootLoc.reserve(m_oWorld.GetEnemyHills().size() + m_oWorld.GetFoods().size());
for (uint i=0 ; i<m_oWorld.GetEnemyHills().size() ; ++i)
{
aLootLoc.push_back(m_oWorld.GetEnemyHills()[i]);
}
for (uint i=0 ; i<m_oWorld.GetFoods().size() ; ++i)
{
aLootLoc.push_back(m_oWorld.GetFoods()[i]);
}
if (aLootLoc.size())
{
vector<Vector2> aLootAnt;
for (uint i=0 ; i<m_oWorld.GetAntCount() ; ++i)
{
Ant& oAnt = m_oWorld.GetAnt(i);
if (oAnt.GetPlayer() > 0) continue;
if (oAnt.GetRole() == Attack) continue;
aLootAnt.push_back(oAnt.GetLocation());
}
m_oNavDijkstra.Explore(aLootLoc, aLootAnt, 0, m_oWorld.GetTurn());
#ifdef MYDEBUG
//m_oNavDijkstra.PrintDebug();
#endif
typedef map<Vector2, set<Path>> AllPathMap;
typedef pair<Vector2, set<Path>> AllPathPair;
AllPathMap aAllPath;
for (uint i=0 ; i<aLootAnt.size() ; ++i)
{
Path oPath;
if (m_oNavDijkstra.GetPath(aLootAnt[i], oPath))
{
Vector2 start = oPath.GetStart();
AllPathMap::iterator it = aAllPath.find(start);
if (it == aAllPath.end())
{
pair<AllPathMap::iterator, bool> res = aAllPath.insert(AllPathPair(start, set<Path>()));
it = res.first;
}
it->second.insert(oPath);
//.........这里部分代码省略.........