X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=node.cpp;h=1fb2b2e3ee9448eeb50a7f0657e23f1082f72895;hb=e26fd7b3195576b25ffe51253a391b53f412a650;hp=11fed08507b52bfe5953a1558aed3c3e2be6818a;hpb=dc49c0c521090f0eb4b9692b25a129537c07e19e;p=popboot.git diff --git a/node.cpp b/node.cpp index 11fed08..1fb2b2e 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(); +} + +const Action& Node::action() const{ + return _action; +} + + +void Node::addChild(Node* node){ + _children.push_back(node); +} + + +void Node::execute(const literals& effects){ + for (literals::const_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()); + } }