? t3.gz ? doc/README.sound ? m4/esd.m4 ? m4/sdl.m4 ? server/path_finding10.c ? server/path_finding10.h Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.199 diff -u -r1.199 aiunit.c --- ai/aiunit.c 2002/05/24 07:59:04 1.199 +++ ai/aiunit.c 2002/06/05 15:13:58 @@ -36,6 +36,7 @@ #include "diplomats.h" #include "gotohand.h" #include "maphand.h" +#include "path_finding10.h" #include "settlers.h" #include "unithand.h" #include "unittools.h" @@ -450,14 +451,17 @@ int most_unknown = 0; /* Desired destination */ int best_x = -1, best_y = -1; - - generate_warmap(map_get_city(x, y), punit); - - /* XXX: There's some duplicate code here, but it's several tiny pieces, - * impossible to group together and not worth their own function - * separately. --pasky */ - - whole_map_iterate(x1, y1) { + /* Map for eXploring */ + pf_map_t x_map = pf_init_map(punit); + /* THe maximum number of unknown tiles we could possibly uncover */ + int max_uncover = (2 * range + 1) * (2 * range + 1); + /* Early stop condition */ + bool early_stop = FALSE; + + while (pf_iterate_map(x_map) && !early_stop) { + /* The current coordinates */ + int x1 = pf_get_current_x(x_map); + int y1 = pf_get_current_y(x_map); /* The actual map tile */ struct tile *ptile = map_get_tile(x1, y1); @@ -473,15 +477,16 @@ unknown++; } square_iterate_end; - if (unknown > 0) { #define COSTWEIGHT 9 + if (unknown > 0) { /* How far it's worth moving away */ int threshold = THRESHOLD * move_rate; + /* How close we are to the sensible boundary */ + int dist_to_threshold + = COSTWEIGHT * (threshold - pf_get_current_cost(x_map)); - if (is_sailing_unit(punit)) - unknown += COSTWEIGHT * (threshold - warmap.seacost[x1][y1]); - else - unknown += COSTWEIGHT * (threshold - warmap.cost[x1][y1]); + unknown += dist_to_threshold; + /* FIXME? Why we don't do same tests like in part 2? --pasky */ if (((unknown > most_unknown) || @@ -490,15 +495,22 @@ best_x = x1; best_y = y1; most_unknown = unknown; + } else if (dist_to_threshold + max_uncover < most_unknown) { + /* We cannot possibly increase most_unknown, + * it's time to stop */ + early_stop = TRUE; } #undef COSTWEIGHT } } - } whole_map_iterate_end; + } + pf_destroy_map(x_map); if (most_unknown > 0) { /* Go there! */ - + + freelog(LOG_NORMAL, "Exploring %s(%d,%d) wants to go to (%d,%d)", + unit_type(punit)->name, punit->x, punit->y, best_x, best_y); punit->goto_dest_x = best_x; punit->goto_dest_y = best_y; handle_unit_activity_request(punit, ACTIVITY_GOTO); Index: server/Makefile.am =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/Makefile.am,v retrieving revision 1.22 diff -u -r1.22 Makefile.am --- server/Makefile.am 2001/06/15 23:12:59 1.22 +++ server/Makefile.am 2002/06/05 15:13:59 @@ -41,6 +41,8 @@ maphand.h \ meta.c \ meta.h \ + path_finding10.c \ + path_finding10.h \ plrhand.c \ plrhand.h \ report.c \ @@ -71,3 +73,4 @@ civserver_DEPENDENCIES = ../common/libcivcommon.a ../ai/libcivai.a ./libcivserver.a civserver_LDADD = ../common/libcivcommon.a ../ai/libcivai.a ./libcivserver.a @INTLLIBS@ ../common/libcivcommon.a ../ai/libcivai.a ./libcivserver.a $(SERVER_LIBS) +