]> ruin.nu Git - popboot.git/blobdiff - node.cpp
delete remaining actions
[popboot.git] / node.cpp
index 899f38bf325592f2a9fa200f48edfb0acf5cb66c..b4d22fb9569c28cea70176abce6ce585c2b8b8c1 100644 (file)
--- a/node.cpp
+++ b/node.cpp
@@ -3,9 +3,9 @@
 #include <iostream>
 using namespace std;
 
-Node::Node(const Action& action){
+Node::Node(const Action* action){
        _action = action;
-       _preconditions = _action.preconditions();
+       _preconditions = _action->preconditions();
        _executed = false;
 }
 Node::Node(){
@@ -18,7 +18,7 @@ Node::Node(const Node& node){
        _executed = node._executed;
 }
 
-const Action& Node::action() const{
+const Action* Node::action() const{
        return _action;
 }
 
@@ -34,9 +34,12 @@ 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;
+       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));
@@ -48,8 +51,8 @@ void Node::execute(const Literals& effects){
                return;
 
        _executed = true;
-       int value = _action.execute();
-       _effects = _action.effects(value);
+       int value = _action->execute();
+       _effects = _action->effects(value);
 
        cerr << "Got returnvalue: " << value << ", number of effects: " << _effects.size() << endl;
 
@@ -61,14 +64,14 @@ void Node::execute(const Literals& effects){
 StartNode::StartNode(const Literals& init){
        EffectsMap initial;
        initial[0] = init;
-       _action = Action("start",Preconditions(),"", initial);
+       _action = new Action("start",Preconditions(),"", initial);
 }
 
 EndNode::EndNode(const Literals& goal){
        Preconditions goalState;
        for(Literals::const_iterator g = goal.begin(); g != goal.end(); ++g)
                goalState[*g] = true;
-       _action = Action("finish",goalState,"",EffectsMap());
-       _preconditions = _action.preconditions();
+       _action = new Action("finish",goalState,"",EffectsMap());
+       _preconditions = _action->preconditions();
 }