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