URL:
  <http://gna.org/patch/?3856>

                 Summary: Add nativity check for find_closest_city()
                 Project: Freeciv
            Submitted by: persia
            Submitted on: Sat 20 Apr 2013 08:55:07 AM JST
                Category: general
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 

    _______________________________________________________

Details:

The find_closest_city() function takes an is_ocean parameter that is used for
two different purposes: to identify nativity given certain assumptions, and to
find coastal/border cities.  The attached patch extends this function to take
a unit_class argument used for nativity identification, and replaces the use
of is_ocean in three places:

1) When the AI has a defending unit with nothing to do (e.g. city disbanded),
that unit currently looks for a new city with an apparently reversed nativity
check: UMT_LAND units head for coastal cities, and other units (sea/air) look
for the closest city (which may not be reachable for sea units).  This patch
causes bored defenders to seek a native city.  Autogame testing showed some
differences with this change, although I was unable to idenfity specific
generalisation of behaviour: my assumption is that sea units are more likely
to rest in cities (where they are potentially defended by land units), and
that land units might choose to fortify in other land cities (potentially
closer to land borders).

2) When creating a new unit with the editor, assign a homecity that is native
to the class being created, rather than only doing this for UMT_SEA units.

3) When teleporting a UTYF_UNDISBANDABLE unit in try_to_save_unit(), teleport
to a city native to the transport, rather than always a coastal city.  This
only affects rulesets with non-UMT_SEA transports that can carry
UTYF_UNDISBANDABLE units, so results were not shown in any of my autogame
testing (no differences, but not actually exercised meaningfully).

    This patch does not attempt to remove the is_ocean argument entirely. 
This remains useful for dai_manage_diplomat(), where the intent is to send
bored diplomats to coastal cities to help defend the edges of the continent in
cases where there is no access to other civilisations by land.  Once AI
diplomats learn how to use transport, this argument may be safely removed. 
Alternately, this could usefully be adjusted to indicate border/coastal cities
rather than is_ocean: the current model behaves suboptimally when cities are
adjacent to small lakes (also not addressed by this patch).

Note that this patch expects prior application of the wipe_unit() refactoring
from patch #3804 (and bug# 20744).



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sat 20 Apr 2013 08:55:07 AM JST  Name: native-find-closest-city.patch 
Size: 9kB   By: persia

<http://gna.org/patch/download.php?file_id=17777>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?3856>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to