Browse Source

setable center point

Kajetan Johannes Hammerle 3 years ago
parent
commit
be413b7409
1 changed files with 12 additions and 3 deletions
  1. 12 3
      Main.cpp

+ 12 - 3
Main.cpp

@@ -133,13 +133,22 @@ long getNanos() {
     return std::chrono::high_resolution_clock::now().time_since_epoch().count();
 }
 
-int main() {
+int main(int argAmount, char** args) {
     long start = -getNanos();
 
     if(r.read("romaniaroads.pl")) {
         return 0;
     }
-    findCenter();
+    if(argAmount >= 2) {
+        int c = atoi(args[1]);
+        if(c < 0 || c >= r.getSize()) {
+            std::cout << c << " is not a valid center\n";
+            return 0;
+        }
+        center = c;
+    } else {
+        findCenter();
+    }
 
     r.print();
 
@@ -149,7 +158,7 @@ int main() {
     init();
     sort();
 
-    for(int gens = 0; gens < 250; gens++) {
+    for(int gens = 0; gens < 500; gens++) {
         size_t half = population.size() / 2;
         for(size_t i = half; i < population.size(); i++) {
             int parent = rand() % half;