X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=main.cpp;h=740c8890771f2cf81bf61458b9ee2e970ce60d9d;hp=15bca93ef2bcfcdf984c006231bef685b267624b;hb=9811871585fa6028362c8910bfac18159c286323;hpb=b177aeec472c3941b39b874a83883ff87a41919c diff --git a/main.cpp b/main.cpp index 15bca93..740c889 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,46 @@ #include +#include +#include using namespace std; +#include "planner.h" +#include "action.h" + +vector stringToVector(string str){ + vector 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] << " \"init state\" \"goal state\"" << endl; + return 1; + } + + ifstream file(argv[1]); + if (!file){ + cerr << "Cannot open input file: " << argv[1] << endl; + exit(2); + } + vector 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; }