- if (absolute <= strat->absolute &&
- perleague <= strat->perleague)
- return absolute;
-
- debugf(" SOMEHOW BEST\n");
-
- fildebugf("final %d:%3d mid %d ",finarch,finisle,midarch);
-
-#define CHK(absperl) \
- fildebugf(#absperl " %15f", absperl); \
- if (absperl < strat->absperl) { \
- debugf(" "); \
- } else { \
- int pos; \
- ctr_newbests_strat_##absperl++; \
- strat->absperl= absperl; \
- memcpy(strat->absperl##_ports, ports, sizeof(*ports) * nports); \
- if (nports < MAX_ROUTELEN-1) strat->absperl##_ports[nports]= -1; \
- fildebugf("** "); \
- for (pos=0; pos < nhighscores_##absperl; pos++) \
- if (highscores_##absperl[pos].pr == strat) goto found_##absperl; \
- /* not found */ \
- pos= -1; \
- found_##absperl: \
- for (;;) { \
- pos++; \
- if (pos >= nhighscores_##absperl-1) break; /* new top */ \
- if (highscores_##absperl[pos].value >= absperl) break; /* found spot */ \
- if (pos>0) \
- highscores_##absperl[pos-1]= highscores_##absperl[pos]; \
- } \
- pos--; \
- if (pos>0) { \
- highscores_##absperl[pos].value= absperl; \
- highscores_##absperl[pos].pr= strat; \
- } \
- fildebugf("@%2d", pos); \
- }
-
- CHK(absolute)
- CHK(perleague)
+ for (granui=granus-1; granui>=0; granui--) {
+ Bucket *bucket= buckets[granui];
+
+ if (value[A] <= bucket->prs[A].value[A] &&
+ value[P] <= bucket->prs[P].value[P])
+ continue;
+
+ debugf(" SOMEHOW %d BEST\n",granui);
+
+ fildebugf("granu %d f%d:%3d mid%d:%3d ",granui,
+ finarch,finisle,midarch,midisle);
+
+ for (ap=0; ap<AP; ap++) {
+ HighScoreEntry *scores= highscores[granui][ap];
+ int nscores= nhighscores[granui][ap];
+
+ fildebugf("ap=%d %15f", ap, value[ap]);
+ if (value[ap] < bucket->prs[ap].value[ap]) {
+ debugf(" ");
+ } else {
+ int pos;
+ ctr_newbests_granu[granui*AP+ap]++;
+ bucket->prs[ap].length= totaldist;
+ memcpy(bucket->prs[ap].value, value, sizeof(value));
+ memcpy(bucket->prs[ap].ports, ports, sizeof(*ports) * nports);
+ if (nports < MAX_ROUTELEN-1) bucket->prs[ap].ports[nports]= -1;
+ fildebugf("** ");
+ for (pos=0; pos < nscores; pos++)
+ if (scores[pos].bucket == bucket) goto found;
+ /* not found */
+ pos= -1;
+ found:
+ for (;;) {
+ pos++;
+ if (pos >= nscores) break; /* new top */
+ if (scores[pos].value >= value[ap]) break; /* found spot */
+ if (pos>0)
+ scores[pos-1]= scores[pos];
+ }
+ pos--;
+ if (pos>0) {
+ scores[pos].value= value[ap];
+ scores[pos].bucket= bucket;
+ if (granui < granus-1 &&
+ highscores[granui][A][0].bucket &&
+ highscores[granui][P][0].bucket) {
+ /* both absolute and perleague are full at this granularity,
+ * so we don't care about anything more granular */
+ fildebugf("\n STOP-GRANU ");
+ granus= granui+1;
+ }
+ }
+ fildebugf("@%2d/%2d ", pos, nscores);
+ } /* new best */
+ } /* ap */
+ } /* granui */