]> ruin.nu Git - popboot.git/blobdiff - main.cpp
seems to work
[popboot.git] / main.cpp
index 15bca93ef2bcfcdf984c006231bef685b267624b..740c8890771f2cf81bf61458b9ee2e970ce60d9d 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1,7 +1,46 @@
 #include <iostream>
+#include <sstream>
+#include <fstream>
 using namespace std;
 
+#include "planner.h"
+#include "action.h"
+
+vector<string> stringToVector(string str){
+       vector<string> strings;
+
+       istringstream ist(str);
+       while (ist >> str){
+               strings.push_back(str);
+       }
+
+       return strings;
+}
+
 int main(int argc, char** argv){
+       
+       if (argc != 4){
+               cout << "Syntax: " << argv[0] << " <file> \"init state\" \"goal state\"" << endl;
+               return 1;
+       }
+
+       ifstream file(argv[1]);
+       if (!file){
+               cerr << "Cannot open input file: " << argv[1] << endl;
+               exit(2);
+       }
 
+       vector<Action> actions;
+       while (!file.eof()){
+               string exec;
+               string precond;
+               string effects;
+               getline(file,exec);
+               getline(file,effects);
+               getline(file,precond);
+               cout << exec << ":" << effects << ":" << precond << endl;
+               actions.push_back(Action(exec, stringToVector(precond), stringToVector(effects)));
+       }
+       Planner p(actions, stringToVector(argv[2]), stringToVector(argv[3]));
        return 0;
 }