X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=node.cpp;h=fb1c314dcf682a059c3eff9d7235885d214bf2a7;hb=dc4211bc1dc77ba3f1a71ec5737c61731614004b;hp=1efdf6a03199e01f882e27e4d4d7de499f01a27b;hpb=c9c72023d15decebe700ad0bfe3e8cbac9a85248;p=popboot.git diff --git a/node.cpp b/node.cpp index 1efdf6a..fb1c314 100644 --- a/node.cpp +++ b/node.cpp @@ -1,5 +1,6 @@ #include "node.h" #include +#include using namespace std; Node::Node(const Action& action){ @@ -33,27 +34,30 @@ bool Node::executed() const{ const Literals& Node::effects() const{ return _effects; } +void Node::satisfyCondition(std::string effect){ + _preconditions.erase(_preconditions.find(effect)); +} void Node::execute(const Literals& effects){ + cerr << "Executing: " << _action.name() << endl; for (Literals::const_iterator effect = effects.begin(); effect != effects.end(); ++effect){ + cerr << "Satisfied effect: " << *effect << endl; _preconditions.erase(_preconditions.find(*effect)); } + cerr << "Number of preconditions left: " << _preconditions.size() << endl; + if(_executed) + cerr << "Already executed" << endl; if ((_preconditions.size() != 0) || _executed) return; - if (_preconditions.size() != 0){ - for (Preconditions::iterator precond = _preconditions.begin(); precond != _preconditions.end(); ++precond){ - if (precond->second) - return; - } - } - _executed = true; int value = _action.execute(); _effects = _action.effects(value); + cerr << "Got returnvalue: " << value << ", number of effects: " << _effects.size() << endl; + for(vector::iterator child = _children.begin(); child != _children.end(); ++child){ - (*child)->execute(effects); + (*child)->execute(_effects); } }