X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=node.cpp;h=1fb2b2e3ee9448eeb50a7f0657e23f1082f72895;hb=e26fd7b3195576b25ffe51253a391b53f412a650;hp=ed72a7f60c5a5e289c33fe36592a715d4ec29cc1;hpb=498b277372ebab0008b97399d387285b36d88826;p=popboot.git diff --git a/node.cpp b/node.cpp index ed72a7f..1fb2b2e 100644 --- a/node.cpp +++ b/node.cpp @@ -1,11 +1,13 @@ #include "node.h" +#include using namespace std; Node::Node(Action action){ _action = action; + _preconditions = _action.preconditions(); } -Action Node::action(){ +const Action& Node::action() const{ return _action; } @@ -15,10 +17,15 @@ void Node::addChild(Node* node){ } -void Node::execute(){ +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(); + (*child)->execute(_action.effects()); } }