Author: sveinung
Date: Tue Sep  1 12:19:50 2015
New Revision: 29751

URL: http://svn.gna.org/viewcvs/freeciv?rev=29751&view=rev
Log:
ai: value immunity against more action types

in the city independent governments evaluation code. This value is useful if
an AI select a government without having any cities.

Keep the old values of 4 for immunity to being incited and 2 for immunity
against being bribed. Add a value of 0.1 for immunity to investigate city,
poison city, steal gold, sabotage city, targeted sabotage city, tech theft,
targeted tech theft, sabotage unit, capture units, steal map, bombard,
briefcase nuke, explode nuclear, destroy city and expel unit.

The idea is to value them a bit but without overriding anything well tested.
This is why the same, low value is added for them all even if being the
target of some are much worse than being the target of others.

See patch #6309

Modified:
    trunk/server/advisors/advdata.c

Modified: trunk/server/advisors/advdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advdata.c?rev=29751&r1=29750&r2=29751&view=diff
==============================================================================
--- trunk/server/advisors/advdata.c     (original)
+++ trunk/server/advisors/advdata.c     Tue Sep  1 12:19:50 2015
@@ -811,7 +811,7 @@
 
       if (!override) {
         int dist;
-        int bonus = 0; /* in percentage */
+        adv_want bonus = 0; /* in percentage */
         int revolution_turns;
 
         pplayer->government = gov;
@@ -829,12 +829,65 @@
          * a very small amount here to choose govt in cases where
          * we have no cities yet. */
         bonus += get_player_bonus(pplayer, EFT_VETERAN_BUILD) > 0 ? 3 : 0;
-        if (action_immune_government(gov, ACTION_SPY_INCITE_CITY)) {
-          bonus += 4;
-        }
-        if (action_immune_government(gov, ACTION_SPY_BRIBE_UNIT)) {
-          bonus += 2;
-        }
+
+        /* TODO: Individual and well balanced value. */
+        action_iterate(act) {
+          if (!action_immune_government(gov, act)) {
+            /* This government doesn't provide immunity againt this
+             * action. */
+            continue;
+          }
+
+          switch((enum gen_action)act) {
+          case ACTION_SPY_INCITE_CITY:
+            bonus += 4;
+            break;
+          case ACTION_SPY_BRIBE_UNIT:
+            bonus += 2;
+            break;
+          case ACTION_SPY_INVESTIGATE_CITY:
+          case ACTION_SPY_POISON:
+          case ACTION_SPY_STEAL_GOLD:
+          case ACTION_SPY_SABOTAGE_CITY:
+          case ACTION_SPY_TARGETED_SABOTAGE_CITY:
+          case ACTION_SPY_STEAL_TECH:
+          case ACTION_SPY_TARGETED_STEAL_TECH:
+          case ACTION_SPY_SABOTAGE_UNIT:
+          case ACTION_CAPTURE_UNITS:
+          case ACTION_STEAL_MAPS:
+          case ACTION_BOMBARD:
+          case ACTION_SPY_NUKE:
+          case ACTION_NUKE:
+          case ACTION_DESTROY_CITY:
+          case ACTION_EXPEL_UNIT:
+            /* Being a target of this is usually undesireable */
+            /* TODO: Individual and well balanced values. */
+            bonus += 0.1;
+            break;
+
+          case ACTION_MARKETPLACE:
+          case ACTION_FOUND_CITY:
+            /* Wants the ability to do this to it self. Don't want others
+             * to target it. Do nothing since action_immune_government()
+             * doesn't separate based on who the actor is. */
+            break;
+
+          case ACTION_ESTABLISH_EMBASSY:
+          case ACTION_TRADE_ROUTE:
+          case ACTION_JOIN_CITY:
+          case ACTION_HELP_WONDER:
+            /* Could be good. An embassy gives permanent contact. A trade
+             * route gives gold per turn. Join city gives population. Help
+             * wonder gives shields. */
+            /* TODO: Individual and well balanced values. */
+            break;
+
+          case ACTION_COUNT:
+            /* Invalid */
+            break;
+          }
+        } action_iterate_end;
+
         bonus += get_player_bonus(pplayer, EFT_INSPIRE_PARTISANS) > 0 ? 3 : 0;
         bonus += get_player_bonus(pplayer, EFT_RAPTURE_GROW) > 0 ? 2 : 0;
         bonus += get_player_bonus(pplayer, EFT_FANATICS) > 0 ? 3 : 0;


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

Reply via email to