本文整理汇总了C++中AbstractNode::getChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractNode::getChildren方法的具体用法?C++ AbstractNode::getChildren怎么用?C++ AbstractNode::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractNode
的用法示例。
在下文中一共展示了AbstractNode::getChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isDisjunctionOfComplexConjunctions
bool AbstractNode::isDisjunctionOfComplexConjunctions()
{
if(AbstractNode::TYPE_OPERATION_OR != getType())
return false; //not a disjunction
int numOperations = 0;
ChainIterator<AbstractNode*> *iterator = children->getIterator();
while(true == iterator->hasNext()) {
AbstractNode *child = iterator->next(); //Get an element which might be conjunction
//Disjunction contains elements which are not parts of conjunction
if(!((AbstractNode::TYPE_VARIABLE == child->getType()) ||
(AbstractNode::TYPE_OPERATION_AND == child->getType()) ||
(AbstractNode::TYPE_OPERATION_NOT == child->getType()))) {
return false;
}
if(AbstractNode::TYPE_OPERATION_AND == child->getType()) {
if(child->getChildren()->getSize() > 1)
numOperations++;
}
if(AbstractNode::TYPE_OPERATION_NOT == child->getType()) {
AbstractNode *grandChild = child->getChildren()->getFirstElement();
if(AbstractNode::TYPE_VARIABLE != grandChild->getType()) {
return false; //Contains complex NOT operation
}
}
}
return (numOperations > 0);
}
示例2: consistsFromSimpleElements
bool AbstractNode::consistsFromSimpleElements()
{
ChainIterator<AbstractNode*> *iterator = children->getIterator();
while(true == iterator->hasNext()) {
AbstractNode *child = iterator->next();
if(AbstractNode::TYPE_VARIABLE == child->getType())
continue;
if(AbstractNode::TYPE_OPERATION_NOT == child->getType()) {
AbstractNode *notChild = child->getChildren()->getFirstElement();
if(AbstractNode::TYPE_VARIABLE == notChild->getType())
continue;
}
return false;
}
return true;
}
示例3: computeBestPath
void AStarSearcher::computeBestPath(std::vector<AbstractNode*>& out_path)
{
std::priority_queue<AbstractNode*, std::vector<AbstractNode*>, AStarPriorityQueueComparer> edgeList;
AbstractNode* currentNode = m_rootNode;
while(!currentNode->isEnd())
{
currentNode->spawnChildren();
addExpandedNode();
const std::vector<AbstractNode*>& children = currentNode->getChildren();
for(int i = 0; i < children.size(); i++)
{
edgeList.push(children[i]);
}
if (edgeList.size() == 0)
break;
AbstractNode* nextBest = edgeList.top();
edgeList.pop();
//if we did not select a child node then we have to go back down and up through the tree
if(nextBest->getParent() != currentNode)
goToChild(currentNode, nextBest->getParent());
currentNode = nextBest;
currentNode->onEnter();
}
if (currentNode->isGoal()) {
// Award 100 points
setFinalScore(-currentNode->getTotalCost());
} else {
setFinalScore(-currentNode->getTotalCost());
}
while(currentNode)
{
out_path.insert(out_path.begin(), currentNode);
currentNode = currentNode->getParent();
}
}