[freeciv-ai] (PR#8993) Stop ferries from yoyo-ing between cities
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8993 >
[per wrote]:
>
> As of now, taking 30 turns traveling over half the world to stay
> in a city that will finish its ferry in 31 turns rather than
> staying in a city that will finish its ferry in 32 turns is a
> possible result. What will happen is that both cities will buy
> the ferries before 30 turns because they need
> it and the ferry they already have will be smack between the
> two cities, leaving the player with 3 ferries, one too many.
>
> This example does not really explain the yoyo-ing that I've
> seen, though, so I suspect there are more issues here.
The savegame provided by Per had exactly the behaviour explained
above although without the dramatic buying outcome. The attached
patch is an improved version of Per's original one, but I would
still think hard before applying it. All it does is just removing
the visual sore of yoyoing ferries. What is really needed is military
build code properly checking availability before building a ferry.
This is better done in an organised manner, see (8992).
G.
? aaa.gz
? bbb.gz
? ttt.gz
? ai/aisettler.c
? ai/aisettler.h
? data/flags/Makefile
? data/flags/Makefile.in
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.319
diff -u -r1.319 aiunit.c
--- ai/aiunit.c 14 Jun 2004 10:37:52 -0000 1.319
+++ ai/aiunit.c 15 Jun 2004 16:25:56 -0000
@@ -2316,22 +2316,21 @@
/****************************************************************************
A helper for ai_manage_ferryboat. Finds a city that wants a ferry. It
might signal for the ferry using pcity->ai.choice.need_boat field or
- it might simply be building a ferry of it's own.
+ it might simply be building a ferry of it's own. We choose the closest
+ city to which we can get in time (i.e. before it builds it's own ferry).
The city found will be set as the goto destination.
TODO: lift the path off the map
TODO (possible): put this and ai_ferry_findcargo into one PF-loop. This
- will save some code lines but will be faster in the rare cases when there
- passengers that can not be reached ("false positive").
+ will save some code lines but will be faster only in the rare cases when
+ there are passengers that can not be reached ("false positive").
****************************************************************************/
static bool ai_ferry_find_interested_city(struct unit *pferry)
{
/* Path-finding stuff */
struct pf_map *map;
struct pf_parameter parameter;
- /* Early termination condition */
- int turns_horizon = FC_INFINITY;
/* Future return value */
bool needed = FALSE;
@@ -2352,10 +2351,6 @@
struct city *pcity;
pf_next_get_position(map, &pos);
- if (pos.turn >= turns_horizon) {
- /* Won't be able to find anything better than what we have */
- break;
- }
pcity = map_get_city(pos.x, pos.y);
@@ -2377,12 +2372,6 @@
continue;
}
- if (turns >= turns_horizon) {
- UNIT_LOG(LOGLEVEL_FERRY, pferry, "%s is NOT suitable: "
- "has just started building", pcity->name);
- continue;
- }
-
unit_list_iterate(map_get_tile(pos.x, pos.y)->units, aunit) {
if (aunit != pferry && aunit->owner == pferry->owner
&& unit_has_role(aunit->type, L_FERRYBOAT)) {
@@ -2395,11 +2384,10 @@
} unit_list_iterate_end;
if (really_needed) {
- UNIT_LOG(LOGLEVEL_FERRY, pferry, "will go to %s unless we "
- "find something better", pcity->name);
+ UNIT_LOG(LOGLEVEL_FERRY, pferry, "will go to %s", pcity->name);
set_goto_dest(pferry, pos.x, pos.y);
- turns_horizon = turns;
needed = TRUE;
+ break;
}
}
} while (pf_next(map));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freeciv-ai] (PR#8993) Stop ferries from yoyo-ing between cities,
Gregory Berkolaiko <=
|
|