chiark / gitweb /
WIP routesearch; route high table
[ypp-sc-tools.db-test.git] / yarrg / rsmain.c
index da05f4780fb30ed0256b684aee3c7cea241f5477..b3a6d73c6244a07629e270b3c827608a66fe80df 100644 (file)
@@ -11,6 +11,9 @@ int max_dist= -1;
   COUNTER_LIST
 #undef CTR
 
+static PotentialResult ****results;
+  /* results[start_isle_ix][finalisle][midisle]-> */
+
 int main(int argc, const char **argv) {
   const char *arg;
 
@@ -55,9 +58,73 @@ int main(int argc, const char **argv) {
     double val= value_route(ni, ia, 0);
     printf("route value is %g\n", val);
   } else if (!strcmp(arg,"search")) {
+    MCALLOC(results, argc);
+
     max_dist= atoi(*argv++);
-    while ((arg= *argv++))
-      search(atoi(arg));
+    nhighscores_absolute= atoi(*argv++);
+    nhighscores_perleague= atoi(*argv++);
+
+    MCALLOC(highscores_absolute, nhighscores_absolute);
+    MCALLOC(highscores_perleague, nhighscores_perleague);
+
+    int resultsix= 0;
+    while ((arg= argv[resultsix])) {
+      search(atoi(arg), &results[resultsix]);
+      resultsix++;
+    }
+
+    int i, midarch, finarch;
+    for (i=0; i<resultsix; i++) {
+      fprintf(stderr,"============== start #%d %s ==============\n",
+             i, argv[i]);
+      PotentialResult ***strat_resultsix= results[i];
+      if (!strat_resultsix) continue;
+      fprintf(stderr,"  ");
+      for (midarch=0; midarch<narches; midarch++) {
+       fprintf(stderr,"|   mid %d  ",midarch);
+      }
+      fprintf(stderr,"\n");
+      for (finarch=0; finarch<narches; finarch++) {
+       PotentialResult **strat_finarch= strat_resultsix[finarch];
+       if (!strat_finarch) continue;
+       fprintf(stderr,"f%d",finarch);
+       for (midarch=0; midarch<narches; midarch++) {
+         PotentialResult *result= strat_finarch[midarch];
+         if (!result) {
+           fprintf(stderr,"|          ");
+         } else {
+           fprintf(stderr,"|%5d",(int)(result->absolute));
+           fprintf(stderr," ");
+           fprintf(stderr,"%4d",(int)(result->perleague));
+         }
+       }
+       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 midisle= ports[nports/2]; int midarch= isle2arch(midisle);         \
+      fprintf(stderr,                                                        \
+             " @%2d #%2d | start%3d mid %d:%3d f%d:%3d | %5d %5d %4d |",     \
+             pos, nhighscores_##absperl - 1 - pos,                           \
+             ports[0], midarch,midisle, 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();
   }