chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
routesearch: allow constraining destination island
[ypp-sc-tools.db-live.git]
/
yarrg
/
rssearch.c
diff --git
a/yarrg/rssearch.c
b/yarrg/rssearch.c
index 5c6cc669b183d224923136237528f9eb9261fdb8..fd2e66a16072723ea762e0bd662e4a6af27c298f 100644
(file)
--- a/
yarrg/rssearch.c
+++ b/
yarrg/rssearch.c
@@
-15,6
+15,7
@@
static Neighbour **neighbours; /* neighbours[islandid]->islandid etc. */
static sqlite3_stmt *ss_neigh;
static int ports[MAX_ROUTELEN];
static sqlite3_stmt *ss_neigh;
static int ports[MAX_ROUTELEN];
+static int final_isle;
static Neighbour *get_neighbours(int isle) {
Neighbour **np= &neighbours[isle];
static Neighbour *get_neighbours(int isle) {
Neighbour **np= &neighbours[isle];
@@
-47,6
+48,8
@@
static double process_route(int nports, int totaldist,
ctr_routes_considered++;
ctr_routes_considered++;
+ int wrong_final= final_isle && ports[nports-1] != final_isle;
+
debugf("========== ROUTE");
for (i=0; i<nports; i++)
debugf(" %d",ports[i]);
debugf("========== ROUTE");
for (i=0; i<nports; i++)
debugf(" %d",ports[i]);
@@
-70,6
+73,12
@@
static double process_route(int nports, int totaldist,
}
guess_perleague= guess_absolute / leagues_divisor;
}
guess_perleague= guess_absolute / leagues_divisor;
+ if (wrong_final) {
+ ctr_routes_wrongfinalelim++;
+ debugf(" WFELIM\n");
+ return guess_absolute;
+ }
+
if (guess_absolute <= highscores_absolute[0].value &&
guess_perleague <= highscores_perleague[0].value) {
ctr_routes_quickelim++;
if (guess_absolute <= highscores_absolute[0].value &&
guess_perleague <= highscores_perleague[0].value) {
ctr_routes_quickelim++;
@@
-99,6
+108,11
@@
static double process_route(int nports, int totaldist,
double absolute= value_route(nports, ports, 0);
double perleague= absolute / leagues_divisor;
double absolute= value_route(nports, ports, 0);
double perleague= absolute / leagues_divisor;
+ if (wrong_final) {
+ ctr_routes_wrongfinal++;
+ return absolute;
+ }
+
if (absolute <= strat->absolute &&
perleague <= strat->perleague)
return absolute;
if (absolute <= strat->absolute &&
perleague <= strat->perleague)
return absolute;
@@
-167,8
+181,10
@@
static void recurse(int last_isle,
}
}
}
}
-void search(int start_isle, PotentialResult ****strat_base_io) {
+void search(int start_isle, int final_isle_spec,
+ PotentialResult ****strat_base_io) {
strat_base= ONDEMAND(*strat_base_io, narches);
strat_base= ONDEMAND(*strat_base_io, narches);
+ final_isle= final_isle_spec <= 0 ? 0 : final_isle_spec;
recurse(start_isle,0,0,1e6);
}
recurse(start_isle,0,0,1e6);
}