Author: cazfi
Date: Sun Dec 14 00:22:46 2014
New Revision: 27289

URL: http://svn.gna.org/viewcvs/freeciv?rev=27289&view=rev
Log:
Made HOSTILE_PLAYER() to consider No_Contact players hostile and renamed it as
POTENTIALLY_HOSTILE_PLAYER() to make this clear. It's used for evaluating 
threats,
and we should not assume No_Contact player will be peaceful.
This degrades AI performance a bit while dealing with other default AI players.
Those in fact are guaranteed to go for cease-fire on first contact. As for
playing against human players, this should make it harder for human player to
sneak forces in before first contact to then conquer undefended cities.

See patch #5441

Modified:
    trunk/ai/default/advmilitary.c
    trunk/ai/default/aidiplomat.c
    trunk/ai/default/aitools.c
    trunk/ai/default/aiunit.c
    trunk/ai/default/aiunit.h

Modified: trunk/ai/default/advmilitary.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advmilitary.c?rev=27289&r1=27288&r2=27289&view=diff
==============================================================================
--- trunk/ai/default/advmilitary.c      (original)
+++ trunk/ai/default/advmilitary.c      Sun Dec 14 00:22:46 2014
@@ -1213,7 +1213,7 @@
     /* Rating of enemy defender */
     int vulnerability;
 
-    if (!HOSTILE_PLAYER(ait, pplayer, city_owner(acity))) {
+    if (!POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, city_owner(acity))) {
       /* Not a valid target */
       goto cleanup;
     }

Modified: trunk/ai/default/aidiplomat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aidiplomat.c?rev=27289&r1=27288&r2=27289&view=diff
==============================================================================
--- trunk/ai/default/aidiplomat.c       (original)
+++ trunk/ai/default/aidiplomat.c       Sun Dec 14 00:22:46 2014
@@ -222,7 +222,7 @@
       return;
     }
     incite_cost = city_incite_cost(pplayer, acity);
-    if (HOSTILE_PLAYER(ait, pplayer, city_owner(acity))
+    if (POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, city_owner(acity))
         && is_action_possible_on_city(ACTION_SPY_INCITE_CITY,
                                       pplayer, acity)
         && (incite_cost < INCITE_IMPOSSIBLE_COST)
@@ -587,7 +587,7 @@
     }
 
     if (!pvictim
-        || !HOSTILE_PLAYER(ait, pplayer, unit_owner(pvictim))
+        || !POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, unit_owner(pvictim))
         || unit_list_size(ptile->units) > 1
         || tile_city(ptile)
         || !is_action_enabled_unit_on_unit(ACTION_SPY_BRIBE_UNIT,

Modified: trunk/ai/default/aitools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aitools.c?rev=27289&r1=27288&r2=27289&view=diff
==============================================================================
--- trunk/ai/default/aitools.c  (original)
+++ trunk/ai/default/aitools.c  Sun Dec 14 00:22:46 2014
@@ -197,12 +197,12 @@
 
   /* Estimate enemy attack power. */
   unit_list_iterate(dest_tile->units, aunit) {
-    if (HOSTILE_PLAYER(ait, pplayer, unit_owner(aunit))) {
+    if (POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, unit_owner(aunit))) {
       danger += adv_unit_att_rating(aunit);
     }
   } unit_list_iterate_end;
   dcity = tile_city(dest_tile);
-  if (dcity && HOSTILE_PLAYER(ait, pplayer, city_owner(dcity))) {
+  if (dcity && POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, city_owner(dcity))) {
     /* Assume enemy will build another defender, add it's attack strength */
     struct unit_type *d_type = dai_choose_defender_versus(dcity, punit);
 

Modified: trunk/ai/default/aiunit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiunit.c?rev=27289&r1=27288&r2=27289&view=diff
==============================================================================
--- trunk/ai/default/aiunit.c   (original)
+++ trunk/ai/default/aiunit.c   Sun Dec 14 00:22:46 2014
@@ -986,7 +986,7 @@
     struct city *pcity = tile_city(tile1);
 
     if (pcity
-        && HOSTILE_PLAYER(ait, pplayer, city_owner(pcity))
+        && POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, city_owner(pcity))
        && (dest || !has_defense(pcity))) {
       int attacks;
       struct ai_city *city_data = def_ai_city_data(pcity, ait);
@@ -1158,8 +1158,8 @@
 
   /* Reset enemy cities data. */
   players_iterate(aplayer) {
-    /* See comment below in next usage of HOSTILE_PLAYER. */
-    if ((punit->id == 0 && !HOSTILE_PLAYER(ait, pplayer, aplayer))
+    /* See comment below in next usage of POTENTIALLY_HOSTILE_PLAYER. */
+    if ((punit->id == 0 && !POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer))
         || (punit->id != 0 && !pplayers_at_war(pplayer, aplayer))) {
       continue;
     }
@@ -1278,7 +1278,7 @@
      * which units to build, we want to calculate in danger and which
      * players we want to make war with in the future. We do _not_ want
      * to do this when actually making attacks. */
-    if ((punit->id == 0 && !HOSTILE_PLAYER(ait, pplayer, aplayer))
+    if ((punit->id == 0 && !POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer))
         || (punit->id != 0 && !pplayers_at_war(pplayer, aplayer))) {
       continue; /* Not an enemy. */
     }

Modified: trunk/ai/default/aiunit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiunit.h?rev=27289&r1=27288&r2=27289&view=diff
==============================================================================
--- trunk/ai/default/aiunit.h   (original)
+++ trunk/ai/default/aiunit.h   Sun Dec 14 00:22:46 2014
@@ -71,8 +71,8 @@
 #define IS_ATTACKER(punit) \
   (unit_type(punit)->attack_strength \
         > unit_type(punit)->transport_capacity)
-#define HOSTILE_PLAYER(ait, pplayer, aplayer)                            \
-  (WAR(pplayer, aplayer)                                                    \
+#define POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer)               \
+  (WAR(pplayer, aplayer) || NEVER_MET(pplayer, aplayer)                 \
    || dai_diplomacy_get(ait, pplayer, aplayer)->countdown >= 0)
 #define UNITTYPE_COSTS(ut)                                             \
   (ut->pop_cost * 3 + ut->happy_cost                                   \


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

Reply via email to