X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=blobdiff_plain;f=main.cpp;h=4eb71ea59c4bd5f54fecf514cb4443b03232de45;hp=15bca93ef2bcfcdf984c006231bef685b267624b;hb=HEAD;hpb=f082ffc3fe76ecaa2485386ed703530354bc1c10 diff --git a/main.cpp b/main.cpp index 15bca93..4eb71ea 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,49 @@ #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; + if (effects == "") continue; + //actions.push_back(Action(exec, stringToVector(precond), stringToVector(effects))); + } + Planner p(actions, stringToVector(argv[2]), stringToVector(argv[3])); + p.execute(); return 0; }