chiark / gitweb /
routesearch: middle arch is middle in list of arches, not arch of middle isle
[ypp-sc-tools.db-live.git] / yarrg / rsmain.c
index bde48a171209664e18f2d77de80ba5ad4e3c5d9a..9283fbc2c002eb8ca70265bf384681fcb4009828 100644 (file)
@@ -59,16 +59,24 @@ int main(int argc, const char **argv) {
     printf("route value is %g\n", val);
   } else if (!strcmp(arg,"search")) {
     MCALLOC(results, argc);
+
     max_dist= atoi(*argv++);
+    nhighscores_absolute= atoi(*argv++);
+    nhighscores_perleague= atoi(*argv++);
+
+    MCALLOC(highscores_absolute, nhighscores_absolute);
+    MCALLOC(highscores_perleague, nhighscores_perleague);
+
     int resultsix= 0;
-    while ((arg= *argv++)) {
+    while ((arg= argv[resultsix])) {
       search(atoi(arg), &results[resultsix]);
       resultsix++;
     }
 
     int i, midarch, finarch;
     for (i=0; i<resultsix; i++) {
-      fprintf(stderr,"================== start #%d ==================\n",i);
+      fprintf(stderr,"============== start #%d %s ==============\n",
+             i, argv[i]);
       PotentialResult ***strat_resultsix= results[i];
       if (!strat_resultsix) continue;
       fprintf(stderr,"  ");
@@ -93,6 +101,30 @@ int main(int argc, const char **argv) {
        fprintf(stderr,"\n");
       }
     }
+
+    int pos;
+#define OUT(absperl)                                                         \
+    fprintf(stderr,"\n================== " #absperl " ==================\n"); \
+    for (pos=0; pos<nhighscores_##absperl; pos++) {                          \
+      HighScoreEntry *hs= &highscores_##absperl[pos];                        \
+      PotentialResult *pr= hs->pr;                                           \
+      if (!pr) continue;                                                     \
+      const int *const ports= pr->absperl##_ports;                           \
+      int nports;                                                            \
+      for (nports=0; nports<MAX_ROUTELEN && ports[nports]>=0; nports++);      \
+      int finisle= ports[nports-1]; int finarch= isle2arch(finisle);         \
+      int midarch= route2midarch(ports,nports);                                      \
+      fprintf(stderr,                                                        \
+             " @%2d #%2d | start%3d mid%d f%d:%3d | %5d %5d %4d |",     \
+             pos, nhighscores_##absperl - 1 - pos,                           \
+             ports[0], midarch, finarch,finisle,                     \
+             (int)hs->value, (int)pr->absolute, (int)pr->perleague);         \
+      for (i=0; i<nports; i++) fprintf(stderr," %d",ports[i]);               \
+      fprintf(stderr,"\n");                                                  \
+    }
+    OUT(absolute)
+    OUT(perleague)
+    
   } else {
     abort();
   }