本文整理汇总了C++中World::GetPinky方法的典型用法代码示例。如果您正苦于以下问题:C++ World::GetPinky方法的具体用法?C++ World::GetPinky怎么用?C++ World::GetPinky使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World::GetPinky方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aStar
//run A* from the closest node to Blinky to the closest node that Pacman is occupying
Direction::Enum aStar(const World& in_ourWorld, PathNode* currentNode, PathNode* targetNode)
{
std::priority_queue<std::shared_ptr<ScoredNode>, std::vector<std::shared_ptr<ScoredNode>>, std::function<bool(std::shared_ptr<ScoredNode>, std::shared_ptr<ScoredNode>)>> frontier(NodeComparer);
std::map<PathNode*, std::shared_ptr<ScoredNode>> processedNodes;
std::map<PathNode*, std::shared_ptr<ScoredNode>> frontierMap;
std::vector<const Pawn* const> ghosts;
ghosts.push_back(&in_ourWorld.GetBlinky());
ghosts.push_back(&in_ourWorld.GetInky());
ghosts.push_back(&in_ourWorld.GetPinky());
ghosts.push_back(&in_ourWorld.GetClyde());
std::shared_ptr<ScoredNode> rootNode = std::make_shared<ScoredNode>(currentNode, 0.f, huristic(*currentNode, *targetNode), Direction::Invalid, nullptr);
frontier.push(rootNode);
frontierMap.insert(std::pair<PathNode*, std::shared_ptr<ScoredNode>>(currentNode, rootNode));
while (frontier.size() > 0 && frontier.top()->node != targetNode)
{
std::shared_ptr<ScoredNode> topNode = frontier.top();
frontier.pop();
auto frontierEntry = frontierMap.find(topNode->node);
//If we are not in the frontier map then this is just garbage to be collected
if (frontierEntry == frontierMap.end())
continue;
frontierMap.erase(frontierEntry);
processedNodes.insert(std::pair<PathNode*, std::shared_ptr<ScoredNode>>(topNode->node, topNode));
Expand(in_ourWorld, topNode, *targetNode, ghosts, frontier, frontierMap, processedNodes);
}
if (frontier.size() > 0)
{
ScoredNode* rootConnection = frontier.top()->GetRootConnection();
if (rootConnection)
return rootConnection->connectionDirection;
}
return Direction::Invalid;
}