FILE *debug_file;
FILE *output;
-DEBUG_DEFINE_SOME_DEBUGF(tableau,tabdebugf);
+#define tabdebugf printf
#define CTR(x) int ctr_##x;
#undef CTR
#undef CTRA
-static PotentialResult ****results;
- /* results[start_isle_ix][finalisle][midisle]-> */
+static PotentialResult ****results[STRATS];
+ /* results[STRATS][start_isle_ix][finalisle][midisle]-> */
static pid_t debugoutpid;
int main(int argc, const char **argv) {
const char *arg;
int i, ap;
+ int strati;
#ifndef debug_flags
debug_flags= ~( dbg_sql2 );
double val= value_route(ni, ia, 0);
fprintf(output, "route value is %g\n", val);
} else if (!strcmp(arg,"search")) {
- MCALLOC(results, argc);
+ for (strati=0; strati<STRATS; strati++)
+ MCALLOC(results[strati], argc);
max_dist= atoi(*argv++);
+
for (ap=0; ap<AP; ap++) {
- nhighscores[ap]= atoi(*argv++);
- MCALLOC(highscores[ap], nhighscores[ap]);
+ int nhs= atoi(*argv++);
+ for (strati=0; strati<STRATS; strati++) {
+ nhighscores[strati][ap]= nhs;
+ MCALLOC(highscores[strati][ap], nhs);
+ }
}
const char *final_isle_spec= *argv++;
else final_isle= atoi(final_isle_spec);
assert(final_isle);
- search(init_isle, final_isle, &results[resultsix]);
+ PotentialResult ****strat_base_io[STRATS];
+ for (strati=0; strati<STRATS; strati++)
+ strat_base_io[strati]= &results[strati][resultsix];
+
+ search(init_isle, final_isle, strat_base_io);
resultsix++;
}
- int midarch, finarch;
- for (i=0; i<resultsix; i++) {
- tabdebugf("============== start #%d %s [PARTIAL] ==============\n",
- i, argv[i]);
- PotentialResult ***strat_resultsix= results[i];
- if (!strat_resultsix) continue;
- tabdebugf(" ");
- for (midarch=0; midarch<narches; midarch++) {
- tabdebugf("| mid %d ",midarch);
- }
- tabdebugf("\n");
- for (finarch=0; finarch<narches; finarch++) {
- PotentialResult **strat_finarch= strat_resultsix[finarch];
- if (!strat_finarch) continue;
- tabdebugf("f%d",finarch);
- for (midarch=0; midarch<narches; midarch++) {
- PotentialResult *result= strat_finarch[midarch];
- if (!result) {
- tabdebugf("| ");
- } else {
- tabdebugf("|%5d",(int)(result->value[A]));
- tabdebugf(" ");
- tabdebugf("%4d",(int)(result->value[P]));
- }
+ int mid, fin;
+ for (strati=minstrat; strati<STRATS; strati++) {
+ fprintf(output,"\n");
+ for (i=0; i<resultsix; i++) {
+ tabdebugf("========== start #%d strati%d %s [PARTIAL] ==========\n",
+ i, strati, argv[i]);
+ PotentialResult ***strat_resultsix= results[strati][i];
+ if (!strat_resultsix) continue;
+ tabdebugf(" ");
+ for (mid=0; mid<stratsz_mid[strati]; mid++) {
+ tabdebugf("| m%-3d ",mid);
}
tabdebugf("\n");
- }
- }
-
- for (ap=0; ap<AP; ap++) {
- int pos;
- fprintf(output,"\n================== ap=%d ==================\n", ap);
- for (pos=0; pos<nhighscores[ap]; pos++) {
- HighScoreEntry *hs= &highscores[ap][pos];
- PotentialResult *pr= hs->pr;
- if (!pr) continue;
- const int *const ports= pr->ports[ap];
- 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(output,
- " @%2d #%2d | start%3d mid%d f%d:%3d | %5d %5d %4d |", \
- pos, nhighscores[ap] - 1 - pos,
- ports[0], midarch, finarch,finisle, \
- (int)hs->value, (int)pr->value[A], (int)pr->value[P]);
- for (i=0; i<nports; i++) fprintf(output," %d",ports[i]);
- fprintf(output,"\n");
- }
- }
+ for (fin=0; fin<stratsz_fin[strati]; fin++) {
+ PotentialResult **strat_fin= strat_resultsix[fin];
+ if (!strat_fin) continue;
+ tabdebugf("f%-3d",fin);
+ for (mid=0; mid<stratsz_mid[strati]; mid++) {
+ PotentialResult *result= strat_fin[mid];
+ if (!result) {
+ tabdebugf("| ");
+ } else {
+ tabdebugf("|%5d",(int)(result->value[A]));
+ tabdebugf(" ");
+ tabdebugf("%4d",(int)(result->value[P]));
+ }
+ }
+ tabdebugf("\n");
+ }
+ } /* i */
+
+ for (ap=0; ap<AP; ap++) {
+ int pos;
+ fprintf(output,"============== strati%d ap=%d ==============\n",
+ strati, ap);
+ for (pos=0; pos<nhighscores[strati][ap]; pos++) {
+ HighScoreEntry *hs= &highscores[strati][ap][pos];
+ PotentialResult *pr= hs->pr;
+ if (!pr) continue;
+ const int *const ports= pr->ports[ap];
+ 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= route2midarch(ports,nports);
+ fprintf(output,
+ " @%2d #%2d | start%3d mid%d:%3d f%d:%3d | %5d %5d %4d |",
+ pos, nhighscores[strati][ap] - 1 - pos,
+ ports[0], midarch,midisle, finarch,finisle,
+ (int)hs->value, (int)pr->value[A], (int)pr->value[P]);
+ for (i=0; i<nports; i++) fprintf(output," %d",ports[i]);
+ fprintf(output,"\n");
+ } /* pos */
+ } /* ap */
+ } /* strati */
fprintf(output,"\n");
} else {