]> ruin.nu Git - popboot.git/commitdiff
initial execution of the plan
authorMichael Andreen <harv@ruin.nu>
Fri, 6 May 2005 22:29:25 +0000 (22:29 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 6 May 2005 22:29:25 +0000 (22:29 +0000)
action.cpp
main.cpp
node.cpp
node.h
planner.cpp
planner.h

index 3e9cddf692163b41a515655c33e37ef29bffd270..427440b268c182270bd358d248870de02c78a8be 100644 (file)
@@ -1,4 +1,6 @@
 #include "action.h"
 #include "action.h"
+#include <iostream>
+using namespace std;
 
 Action::Action(std::string executable, literals preconditions, literals effects){
        _executable = executable;
 
 Action::Action(std::string executable, literals preconditions, literals effects){
        _executable = executable;
@@ -21,6 +23,6 @@ literals Action::preconditions() const{
 }
 
 int Action::execute() const{
 }
 
 int Action::execute() const{
-
+       cout << "Executing: " << _executable << endl;
        return 0;
 }
        return 0;
 }
index 740c8890771f2cf81bf61458b9ee2e970ce60d9d..2affab554e32372a66adb1f312adaddd78ed99c6 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -42,5 +42,7 @@ int main(int argc, char** argv){
                actions.push_back(Action(exec, stringToVector(precond), stringToVector(effects)));
        }
        Planner p(actions, stringToVector(argv[2]), stringToVector(argv[3]));
                actions.push_back(Action(exec, stringToVector(precond), stringToVector(effects)));
        }
        Planner p(actions, stringToVector(argv[2]), stringToVector(argv[3]));
+
+       p.execute();
        return 0;
 }
        return 0;
 }
index 4f81069e111eaf55e603c2bfd26b9a312eef216d..ed72a7f60c5a5e289c33fe36592a715d4ec29cc1 100644 (file)
--- a/node.cpp
+++ b/node.cpp
@@ -1,4 +1,5 @@
 #include "node.h"
 #include "node.h"
+using namespace std;
 
 Node::Node(Action action){
        _action = action;
 
 Node::Node(Action action){
        _action = action;
@@ -13,3 +14,11 @@ void Node::addChild(Node* node){
        _children.push_back(node);
 }
 
        _children.push_back(node);
 }
 
+
+void Node::execute(){
+       _action.execute();
+       
+       for(vector<Node*>::iterator child = _children.begin(); child != _children.end(); ++child){
+               (*child)->execute();
+       }
+}
diff --git a/node.h b/node.h
index 31568fc5a6b910ec44a91b7f71c97e0a2d4ab366..3cd3a9eadd050f0de9fa5ab6cc9563386f6eaf01 100644 (file)
--- a/node.h
+++ b/node.h
@@ -10,6 +10,7 @@ class Node {
                Node(Action action);
                void addChild(Node* node);
                Action action();
                Node(Action action);
                void addChild(Node* node);
                Action action();
+               void execute();
 
        protected:
                Action _action;
 
        protected:
                Action _action;
index b675ce061f6f8b29a3e0ee0352548616ab22e715..463049473fe16ce62ac9207bce287f270867da0b 100644 (file)
@@ -6,9 +6,9 @@ using namespace __gnu_cxx;
 
 Planner::Planner(std::vector<Action> actions, literals init, literals goal){
 
 
 Planner::Planner(std::vector<Action> actions, literals init, literals goal){
 
-       _start = new Node(Action("",literals(), init));
+       _start = new Node(Action("start",literals(), init));
        addNode(_start);
        addNode(_start);
-       Node* finish = new Node(Action("",goal,literals()));
+       Node* finish = new Node(Action("finish",goal,literals()));
 
        for(vector<Action>::iterator action = actions.begin(); action != actions.end(); ++action){
                literals effects = action->effects();
 
        for(vector<Action>::iterator action = actions.begin(); action != actions.end(); ++action){
                literals effects = action->effects();
@@ -58,3 +58,8 @@ void Planner::addNode(Node* node){
                _addedNodes[*effect] = node;
        }
 }
                _addedNodes[*effect] = node;
        }
 }
+
+
+void Planner::execute(){
+       _start->execute();
+}
index c74d536b5e5d03ac7f439921bd06a6793c2b715b..ce7aef0ffff7a4cabb977797fcce12e72e336892 100644 (file)
--- a/planner.h
+++ b/planner.h
@@ -40,6 +40,8 @@ class Planner {
        public:
                Planner(std::vector<Action> actions, literals init, literals goal);
 
        public:
                Planner(std::vector<Action> actions, literals init, literals goal);
 
+               void execute();
+
        protected:
 
                void makePlan(Node* node);
        protected:
 
                void makePlan(Node* node);