]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/blobdiff - src/template-with-reset.cc
Add not better counter to template with reset
[hubacji1/iamcar2.git] / src / template-with-reset.cc
index 2266a3e7f4f2cef636942ca62f66fedf7f670eb1..3060190f57fde703bb686b5663d4c8dc0bca8e15 100644 (file)
@@ -2,7 +2,8 @@
 #include <iostream>
 #include <json/json.h>
 #include <vector>
-#include "fiat_punto.h"
+// When the file with precomputed entries is ready.
+//#include "fiat_punto.h"
 #include "pslot.hh"
 #include "rrtsp.hh"
 
@@ -74,6 +75,7 @@ int main()
        unsigned int icnt = 0;
        unsigned int rcnt = 0;
        unsigned int bcnt = 0;
+       unsigned int ncnt = 0; // not better counter
        Json::Value best_path;
        Json::Value pj;
        double cost = 0.0;
@@ -86,11 +88,19 @@ int main()
                        double gc = pj["goal_cc"].asDouble();
                        assert(gc > 0.0);
                        if (cost == 0.0 || gc < cost) {
+                               if (gc < 0.75 * cost) {
+                                       ncnt = 0;
+                               }
                                best_path = pj["path"];
                                cost = gc;
                                bcnt += 1;
+                       } else {
+                               ncnt++;
                        }
                }
+               if (ncnt > 5) {
+                       break;
+               }
                p.reset();
                rcnt += 1;
        }