X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;ds=sidebyside;f=node.cpp;h=dbb099cf47bc5c30fe14b03fe83aad6cd5d53ca9;hb=09f6dfa65b66103c27dc831271d961de9ab0109e;hp=11fed08507b52bfe5953a1558aed3c3e2be6818a;hpb=dc49c0c521090f0eb4b9692b25a129537c07e19e;p=popboot.git diff --git a/node.cpp b/node.cpp index 11fed08..dbb099c 100644 --- a/node.cpp +++ b/node.cpp @@ -1,5 +1,31 @@ #include "node.h" +#include +using namespace std; Node::Node(Action action){ _action = action; + _preconditions = _action.preconditions(); +} + +Action Node::action(){ + return _action; +} + + +void Node::addChild(Node* node){ + _children.push_back(node); +} + + +void Node::execute(literals effects){ + for (literals::iterator effect = effects.begin(); effect != effects.end(); ++effect){ + _preconditions.erase(find(_preconditions.begin(),_preconditions.end(), *effect)); + } + if (_preconditions.size() != 0) + return; + _action.execute(); + + for(vector::iterator child = _children.begin(); child != _children.end(); ++child){ + (*child)->execute(_action.effects()); + } }