本文整理汇总了C++中AStarNode::hasVisited方法的典型用法代码示例。如果您正苦于以下问题:C++ AStarNode::hasVisited方法的具体用法?C++ AStarNode::hasVisited怎么用?C++ AStarNode::hasVisited使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStarNode
的用法示例。
在下文中一共展示了AStarNode::hasVisited方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateAction
//.........这里部分代码省略.........
i_goal = ii;
j_goal = jj;
}
}
}
}
// variables needed in A* search
Fringe fringe;
unsigned int step = 0;
AStarNode *node = new AStarNode(0.0f, aimDist, AI_VIEW_DISTANCE, AI_VIEW_DISTANCE, AI_VIEW_DISTANCE, AI_VIEW_DISTANCE, true, NULL);
int i, j;
bool fieldVisible;
// add initial state to fringe
fringe.push(node);
// do actual A* search
while (step < AI_MAX_STEPS && !fringe.empty())
{
node = fringe.top();
fringe.pop();
i = node->i;
j = node->j;
if (DEBUG_ENEMY)
_AStarFields.push_back((z + j - AI_VIEW_DISTANCE) * FIELD_SIZE + (x + i - AI_VIEW_DISTANCE));
// goal test (stop iteration when goal is reached)
if (i == i_goal && j == j_goal)
break;
// expand node
if (0 <= i - 1 && surroundings[i - 1][j] != BUILDING && !node->hasVisited(i - 1, j))
{
if (node->isVisible)
fieldVisible = isFieldVisible(_position.x, _position.z, i - 1, j, x, z, surroundings);
else
fieldVisible = false;
//fringe.push(AStarNode(node.cost_so_far + 1.0f, dist(x + i - 1 - AI_VIEW_DISTANCE, z + j - AI_VIEW_DISTANCE, playerPosition),
// i - 1, j, fieldVisible ? i - 1 : node.i_aim, fieldVisible ? j : node.j_aim, fieldVisible));
fringe.push(new AStarNode(fieldVisible ? dist(x + i - 1 - AI_VIEW_DISTANCE, z + j - AI_VIEW_DISTANCE, _position) : node->cost_so_far + 1.0f,
dist(x + i - 1 - AI_VIEW_DISTANCE, z + j - AI_VIEW_DISTANCE, playerPosition),
i - 1, j, fieldVisible ? i - 1 : node->i_aim, fieldVisible ? j : node->j_aim, fieldVisible, node));
}
if (i + 1 < 2 * AI_VIEW_DISTANCE + 1 && surroundings[i + 1][j] != BUILDING && !node->hasVisited(i + 1, j))
{
if (node->isVisible)
fieldVisible = isFieldVisible(_position.x, _position.z, i + 1, j, x, z, surroundings);
else
fieldVisible = false;
fringe.push(new AStarNode(fieldVisible ? dist(x + i + 1 - AI_VIEW_DISTANCE, z + j - AI_VIEW_DISTANCE, _position) : node->cost_so_far + 1.0f,
dist(x + i + 1 - AI_VIEW_DISTANCE, z + j - AI_VIEW_DISTANCE, playerPosition),
i + 1, j, fieldVisible ? i + 1 : node->i_aim, fieldVisible ? j : node->j_aim, fieldVisible, node));
}
if (0 <= j - 1 && surroundings[i][j - 1] != BUILDING && !node->hasVisited(i, j - 1))
{
if (node->isVisible)
fieldVisible = isFieldVisible(_position.x, _position.z, i, j - 1, x, z, surroundings);
else
fieldVisible = false;
fringe.push(new AStarNode(fieldVisible ? dist(x + i - AI_VIEW_DISTANCE, z + j - 1 - AI_VIEW_DISTANCE, _position) : node->cost_so_far + 1.0f,
dist(x + i - AI_VIEW_DISTANCE, z + j - 1 - AI_VIEW_DISTANCE, playerPosition),
i, j - 1, fieldVisible ? i : node->i_aim, fieldVisible ? j - 1 : node->j_aim, fieldVisible, node));
}
if (j + 1 < 2 * AI_VIEW_DISTANCE + 1 && surroundings[i][j + 1] != BUILDING && !node->hasVisited(i, j + 1))