X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=node.cpp;h=899f38bf325592f2a9fa200f48edfb0acf5cb66c;hp=1efdf6a03199e01f882e27e4d4d7de499f01a27b;hb=fdcf46671ca1dab0dadb490bb4375dc3dd2fc9a4;hpb=41efed0d6ee664fb79ea21a0e7239edcf51926d8 diff --git a/node.cpp b/node.cpp index 1efdf6a..899f38b 100644 --- a/node.cpp +++ b/node.cpp @@ -1,5 +1,6 @@ #include "node.h" #include +#include using namespace std; Node::Node(const Action& action){ @@ -35,25 +36,25 @@ const Literals& Node::effects() const{ } 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); } }