]> ruin.nu Git - popboot.git/blobdiff - node.cpp
seems to be working now
[popboot.git] / node.cpp
index 1efdf6a03199e01f882e27e4d4d7de499f01a27b..899f38bf325592f2a9fa200f48edfb0acf5cb66c 100644 (file)
--- a/node.cpp
+++ b/node.cpp
@@ -1,5 +1,6 @@
 #include "node.h"
 #include <algorithm>
+#include <iostream>
 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<Node*>::iterator child = _children.begin(); child != _children.end(); ++child){
-               (*child)->execute(effects);
+               (*child)->execute(_effects);
        }
 }