X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Frssearch.c;h=bb84785eef12f3c6ac11819c00511246623482c9;hb=6ab7c759c0aab39bfaf8275041dd39f45062399c;hp=646c796196d69a364034eed7f302a216fe31d040;hpb=d66f27768708df0b8ce256e2d868ff4f7060ef3f;p=ypp-sc-tools.main.git diff --git a/yarrg/rssearch.c b/yarrg/rssearch.c index 646c796..bb84785 100644 --- a/yarrg/rssearch.c +++ b/yarrg/rssearch.c @@ -38,7 +38,7 @@ static Neighbour *get_neighbours(int isle) { } -static PotentialResult ***strat_base; +static PotentialResult ***strat_base[STRATS]; static double process_route(int nports, int totaldist, @@ -79,23 +79,38 @@ static double process_route(int nports, int totaldist, return guess[A]; } - if (guess[A] <= highscores[A][0].value && - guess[P] <= highscores[P][0].value) { + if (guess[A] <= highscores[minstrat][A][0].value && + guess[P] <= highscores[minstrat][P][0].value) { ctr_routes_quickelim++; debugf(" QELIM %f %f\n", guess[A], guess[P]); return guess[A]; } } - int finisle= ports[nports-1]; int finarch= isle2arch(finisle); + int finisle= ports[nports-1]; + int finarch= isle2arch(finisle); + + int midisle= ports[nports/2]; int midarch= route2midarch(ports,nports); - PotentialResult **strat_fin= ONDEMAND(strat_base[finarch], narches); - PotentialResult *strat= ONDEMAND(strat_fin[midarch], 1); + PotentialResult *strats[STRATS]; + int strati; + for (strati=minstrat; strati=2) { - if (guess[A] <= strat->value[A] && - guess[P] <= strat->value[P]) { + if (guess[A] <= strats[minstrat]->value[A] && + guess[P] <= strats[minstrat]->value[P]) { ctr_routes_stratelim++; debugf(" ELIM %f %f\n", guess[A], guess[P]); return guess[A]; @@ -114,43 +129,50 @@ static double process_route(int nports, int totaldist, return value[0]; } - if (value[A] <= strat->value[A] && - value[P] <= strat->value[P]) - return value[A]; - - debugf(" SOMEHOW BEST\n"); - - fildebugf("final %d:%3d mid %d ",finarch,finisle,midarch); - - for (ap=0; apvalue[ap]) { - debugf(" "); - } else { - int pos; - ctr_newbests_strat[ap]++; - strat->value[ap]= value[ap]; - memcpy(strat->ports[ap], ports, sizeof(*ports) * nports); - if (nports < MAX_ROUTELEN-1) strat->ports[ap][nports]= -1; - fildebugf("** "); - for (pos=0; pos < nhighscores[ap]; pos++) - if (highscores[ap][pos].pr == strat) goto found; - /* not found */ - pos= -1; - found: - for (;;) { - pos++; - if (pos >= nhighscores[ap]-1) break; /* new top */ - if (highscores[ap][pos].value >= value[ap]) break; /* found spot */ - if (pos>0) - highscores[ap][pos-1]= highscores[ap][pos]; + for (strati=minstrat; strativalue[A] && + value[P] <= strat->value[P]) + continue; + + debugf(" SOMEHOW %d BEST\n",strati); + + fildebugf("final %d:%3d mid %d ",finarch,finisle,midarch); + + for (ap=0; apvalue[ap]) { + debugf(" "); + } else { + int pos; + ctr_newbests_strat[ap]++; + strat->value[ap]= value[ap]; + memcpy(strat->ports[ap], ports, sizeof(*ports) * nports); + if (nports < MAX_ROUTELEN-1) strat->ports[ap][nports]= -1; + fildebugf("** "); + for (pos=0; pos < *nscores; pos++) + if (scores[pos].pr == strat) goto found; + /* not found */ + pos= -1; + found: + for (;;) { + pos++; + if (pos >= *nscores-1) 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].pr= strat; + } + fildebugf("@%2d", pos); } - pos--; - if (pos>0) { - highscores[ap][pos].value= value[ap]; - highscores[ap][pos].pr= strat; - } - fildebugf("@%2d", pos); } } @@ -164,7 +186,7 @@ static double process_route(int nports, int totaldist, } static void recurse(int last_isle, - int nports, /* excluding last_isle */ + int nports /* excluding last_isle */, int totaldist /* including last_isle */, double last_estimate) { ports[nports++]= last_isle; @@ -181,14 +203,18 @@ static void recurse(int last_isle, } void search(int start_isle, int final_isle_spec, - PotentialResult ****strat_base_io) { - strat_base= ONDEMAND(*strat_base_io, narches); + PotentialResult ****strat_base_io[STRATS]) { + int strati; + for (strati=0; strati