(PR#10216) AI Builds Too Many Transports
"Gregory Berkolaiko" <[email protected]>
| Newsgroups | gmane.games.freeciv.ai |
|---|---|
| Message-ID | <[email protected]> |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10216 > > [[email protected] - Mon Oct 04 01:19:11 2004]: > > I've done some further investigation of this problem. Initially I'd > thought that the city code for emigrating settlers (function > domestic_advisor_choose_build) was building transports for colonists too > often. However, debugging with additional assertions and logging code > suggests that the military advisor is making the decision to build the > numerous transports. > > What seems to happen is this: > > 1) The military advisor (function military_advisor_choose_build) > considers building a naval attacker (for example, a battleship) by > calling ai_choose_attacker(pcity, SEA_MOVING). > > 2) When the military adviser examines whether it can use that attacker > (by calling function kill_something_with), the code can select a land > unit as the target. That is, it can choose a naval bombardment. > > 3) That code (kill_something_with)) then checks whether there is a path > from the city (were the attacker will begin) and the target (the enemy > land unit to be bombarded), using function goto_is_sane. That call is > used to decide whether a land attacker needs a ferry; a land attacker > will need a ferry if there is no valid (land) path from the city to the > target. However, the function is also used for sea attackers. For those > units, the kill_something_with function incorrectly concludes that the > (naval!) attack unit will need a ferry (go_by_boat becomes TRUE). I > guess it is not handling the 'overlap' needed for shore bombardment > properly. > > 4) Consequently, the military adviser decides to build a transport for > some (many?) cases when it should build a naval attacker. > > Note that there is no feed back loop here: the completion of an > additional transport will not diminish the desire to build more transports. > > Does this analysis seem plausible? I'm investigating further, and > testing a candidate fix. Well done, Benedict! Just to confirm your analysis, here is a small patch which fails my autogame pretty soon. I will now investigate why goto_is_sane is failing us. G.
many_boats_bug.diff
(text/plain, 812 B)
? core.10423
? core.10618
Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.174
diff -u -r1.174 advmilitary.c
--- ai/advmilitary.c 29 Sep 2004 02:24:18 -0000 1.174
+++ ai/advmilitary.c 4 Oct 2004 03:44:15 -0000
@@ -1110,6 +1110,10 @@
&best_choice, NULL, U_LAST);
} else {
/* Attract a boat to our city or retain the one that's already here */
+ if (!is_ground_unit(myunit)) {
+ UNIT_LOG(LOG_ERROR, myunit, "Wants a boat, ridiculous!!");
+ }
+ assert(is_ground_unit(myunit));
best_choice.need_boat = TRUE;
process_attacker_want(pcity, benefit, def_type, def_vet, ptile,
&best_choice, ferryboat, boattype);
auto.rc
(application/octet-stream, 91 B) - not displayed