]> ruin.nu Git - popboot.git/blobdiff - planner.cpp
some changes
[popboot.git] / planner.cpp
index e06489642ad8be00f1bd4bbff0ddde98e7e884b2..884567dea5c4329e43b6d0020bd05bd5c12af1fc 100644 (file)
@@ -10,14 +10,16 @@ Planner::Planner(std::vector<Action> actions, Literals init, Literals goal){
        _goal = goal;
        _start = new StartNode(_init);
        _finish = new EndNode(_goal);
+       addNode(_start);
 
        for(vector<Action>::iterator action = actions.begin(); action != actions.end(); ++action){
                const Literals& effects = action->effects(0);
                for (Literals::const_iterator effect = effects.begin(); effect != effects.end(); ++effect){
-                       cerr << "Adding effect: " << *effect << endl;
+                       cerr << "Adding effect: '" << *effect << "', action: " << action->name() << endl;
                        _actions[*effect] = *action;
                }
        }
+       cout << "Number of actions: " << _actions.size() << endl;
        makePlan(_finish);
 }
 
@@ -42,7 +44,7 @@ void Planner::makePlan(Node* node){
                _start->addChild(node);
        }else{
                for (Preconditions::const_iterator precond = preconds.begin(); precond != preconds.end(); ++precond){
-                       cerr << "Looking for: " << precond->first << endl;
+                       cerr << "Looking for: '" << precond->first << "'" <<  endl;
                        hash_map<string,Node*>::iterator addedNode = _addedNodes.find(precond->first);
                        if(addedNode != _addedNodes.end()){
                                cerr << "Using already added node" << endl;
@@ -68,7 +70,9 @@ void Planner::makePlan(Node* node){
 }
 
 void Planner::addNode(Node* node){
+       cerr << "Adding node for action: " << node->action().name() << endl;
        const Literals& effects = node->action().effects(0);
+       cerr << "Number of effects: " << effects.size() << endl;
 
        for (Literals::const_iterator effect = effects.begin(); effect != effects.end(); ++effect){
                cout << "Adding node for effect: " << *effect << endl;