Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: (PR#8543) AI cannot load transports
Home

[Freeciv-Dev] Re: (PR#8543) AI cannot load transports

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8543) AI cannot load transports
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Apr 2004 21:11:34 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8543 >

Per I. Mathisen wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8543 >
> 
> See $subject. Jason?

Um, oops.

This is basically a hard-to-find bug (that the AI doesn't know about 
loading) that is turned into a glaring one because all loading is now 
done from the client.

The AI can load units using handle_unit_load() and handle_unit_unload(). 
  The accuracy of this is probably very good for the AI, since it 
already tracks which units are assigned to which transporters even 
before the loading is done.  (The interface, however, isn't very good 
for the AI.  The AI could just use laod_unit_onto_transporter() and 
unload_unit_from_transporter(), but that would mean it would have to 
duplicate the correctness checks in handle_unit_[un]load.  On the other 
hand the handle_unit_[un]load functions don't give any kind of return 
value to indicate success.)

The AI may need more checks than can_unit_load.  It may, for instance, 
want to know if the unit could be loaded onto the transporter *assuming 
they were at the same position*.  The current can_unit_load function 
checks the position so units on different tiles can't be "loaded". 
Either a virtual unit or a can_unit_load_at_tile (or maybe 
can_unittype_load) function would be helpful here.

Exactly where the load/unload calls should go is hard to say.  Generally 
the loading should replace ACTIVITY_SENTRY calls and the unloading 
should replace ACTIVITY_IDLE calls.  (It seems pointless to sentry AI 
units on boats, but it can still be done if desired.)

Movement should still work for the AI to unload a unit.

The attached patch is a start.  It's untested.  Note that 
handle_unit_load may silently fail if the load isn't possible.

jason

? cma_weirdness
? diff
? client/gui-qpe
? data/civ3
? data/womoks
Index: ai/aitools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v
retrieving revision 1.100
diff -u -r1.100 aitools.c
--- ai/aitools.c        25 Feb 2004 20:23:49 -0000      1.100
+++ ai/aitools.c        20 Apr 2004 04:10:08 -0000
@@ -292,7 +292,7 @@
 
       UNIT_LOG(LOGLEVEL_GOTHERE, punit, "got boat[%d], going (%d,%d)",
                ferryboat->id, dest_x, dest_y);
-      handle_unit_activity_request(punit, ACTIVITY_SENTRY);
+      handle_unit_load(pplayer, punit->id, ferryboat->id);
       ai_set_passenger(ferryboat, punit);
 
       /* If the location is not accessible directly from sea
@@ -316,7 +316,6 @@
       UNIT_LOG(LOGLEVEL_GOTHERE, punit, "All aboard!");
       set_goto_dest(ferryboat, beach_x, beach_y);
       set_goto_dest(punit, dest_x, dest_y);
-      handle_unit_activity_request(punit, ACTIVITY_SENTRY);
       /* Grab bodyguard */
       if (bodyguard
           && !same_pos(punit->x, punit->y, bodyguard->x, bodyguard->y)) {
@@ -339,7 +338,7 @@
       }
       if (bodyguard) {
         assert(same_pos(punit->x, punit->y, bodyguard->x, bodyguard->y));
-        handle_unit_activity_request(bodyguard, ACTIVITY_SENTRY);
+       handle_unit_load(pplayer, bodyguard->id, ferryboat->id);
       }
       if (!ai_unit_goto(ferryboat, beach_x, beach_y)) {
         /* died */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#8543) AI cannot load transports, Jason Short <=