本文整理汇总了C++中AStarNode::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ AStarNode::Set方法的具体用法?C++ AStarNode::Set怎么用?C++ AStarNode::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStarNode
的用法示例。
在下文中一共展示了AStarNode::Set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExpandNode
inline bool AStar::ExpandNode()
{
// Get the min-weight element off the fringe.
std::pop_heap(FringeNodes.begin(), FringeNodes.end(), NodeGreaterThan());
CurrentNode = FringeNodes.back();
FringeNodes.pop_back();
MapCoordinates TestCoordinates = CurrentNode->LocationCoordinates;
if (VisitedCoordinates.find(TestCoordinates) != VisitedCoordinates.end())
{
return false;
}
if (TestCoordinates == GoalCoordinates)
{
return true; //GenerateBestPath();
}
// mark as VisitedCoordinates if not already VisitedCoordinates
VisitedCoordinates.insert(TestCoordinates);
MapCoordinates NeiboringCoordinates;
DirectionFlags TestDirections = SearchGraph->getDirectionFlags(TestCoordinates);
// Check all Neibors
for (uint8_t i = 0, DirectionType = Direction::ANGULAR_DIRECTIONS[i]; i < NUM_ANGULAR_DIRECTIONS; ++i, DirectionType = Direction::ANGULAR_DIRECTIONS[i])
{
if (TestDirections & (1 << i)) // Connectivity is valid for this direction
{
NeiboringCoordinates = TestCoordinates;
NeiboringCoordinates.TranslateMapCoordinates(DirectionType);
// If Coordinate is not already on the VisitedCoordinates list
if (VisitedCoordinates.find(NeiboringCoordinates) == VisitedCoordinates.end())
{
float EdgeCost = SearchGraph->getEdgeCost(TestCoordinates, DirectionType);
GraphReads++;
AStarNode* NewNode = NodePool->ProvideObject();
NewNode->Set(NeiboringCoordinates, CurrentNode, DirectionType, CurrentNode->PathLengthFromStart + EdgeCost, MainHeuristic->Estimate(NeiboringCoordinates, GoalCoordinates), TieBreakerHeuristic->Estimate(NeiboringCoordinates, GoalCoordinates));
// Add the new Node to the Fringe
FringeNodes.push_back(NewNode);
std::push_heap(FringeNodes.begin(), FringeNodes.end(), NodeGreaterThan());
}
}
}
return false; // Goal was not found
}
示例2: setEndPoints
void AStar::setEndPoints(const MapCoordinates &StartCoords, const MapCoordinates &GoalCoords)
{
StartCoordinates = StartCoords;
GoalCoordinates = GoalCoords;
GraphReads = ExpandedNodes = 0;
FinalPath = NULL;
FringeExausted = false;
FringeNodes.clear();
VisitedCoordinates.clear();
NodePool->Wipe();
AStarNode* StartNode = NodePool->ProvideObject();
StartNode->Set(StartCoordinates, NULL, DIRECTION_NONE, 0, MainHeuristic->Estimate(StartCoords, GoalCoords), TieBreakerHeuristic->Estimate(StartCoords, GoalCoords));
FringeNodes.push_back(StartNode);
std::make_heap(FringeNodes.begin(), FringeNodes.end(), NodeGreaterThan());
//VisitedCoordinates.insert(StartCoordinates);
};