SpaceNode::SpaceNode() : Node(-1, false), nstatus(0) { setStatus(UNDETERMINED); setHasSolvedChildren(false); setHasFailedChildren(false); }
inline SpaceNode::SpaceNode(int p) : Node(p), nstatus(0) { setStatus(UNDETERMINED); setHasSolvedChildren(false); setHasFailedChildren(false); }
forceinline SpaceNode::SpaceNode(int p) : Node(p), copy(NULL), nstatus(0) { choice = NULL; setStatus(UNDETERMINED); setHasSolvedChildren(false); setHasFailedChildren(false); }
void SpaceNode::closeChild(const NodeAllocator& na, bool hadFailures, bool hadSolutions) { setHasFailedChildren(hasFailedChildren() || hadFailures); setHasSolvedChildren(hasSolvedChildren() || hadSolutions); bool allClosed = true; for (int i=getNumberOfChildren(); i--;) { if (getChild(na,i)->isOpen()) { allClosed = false; break; } } if (allClosed) { setHasOpenChildren(false); for (unsigned int i=0; i<getNumberOfChildren(); i++) setHasSolvedChildren(hasSolvedChildren() || getChild(na,i)->hasSolvedChildren()); SpaceNode* p = getParent(na); if (p != nullptr) { p->closeChild(na, hasFailedChildren(), hasSolvedChildren()); } } else { if (hadSolutions) { setHasSolvedChildren(true); SpaceNode* p = getParent(na); while (p != nullptr && !p->hasSolvedChildren()) { p->setHasSolvedChildren(true); p = p->getParent(na); } } if (hadFailures) { SpaceNode* p = getParent(na); while (p != nullptr && !p->hasFailedChildren()) { p->setHasFailedChildren(true); p = p->getParent(na); } } } }