Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9683) Remove AI hints from govts
Home

[Freeciv-Dev] (PR#9683) Remove AI hints from govts

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9683) Remove AI hints from govts
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Thu, 12 Aug 2004 00:39:30 -0700
Reply-to: rt@xxxxxxxxxxx

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

This patch removes some dead and/or useless code from governments which
try give "hints" to the AI. subgoals are not used at all, nor is the
"favours_growth" hint, and the "is_nice" hint is totally braindead and
should never have been sent to the client.

  - Per

Index: ai/advspace.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advspace.c,v
retrieving revision 1.9
diff -u -r1.9 advspace.c
--- ai/advspace.c       28 Nov 2003 17:37:18 -0000      1.9
+++ ai/advspace.c       12 Aug 2004 07:34:23 -0000
@@ -32,7 +32,6 @@
 
 bool ai_spaceship_autoplace(struct player *pplayer, struct player_spaceship 
*ship)
 {
-  struct government *g = get_gov_pplayer(pplayer);
   enum spaceship_place_type type;
   int num, i;
   bool retval = FALSE;
@@ -40,11 +39,6 @@
   while (ship->modules > (ship->habitation + ship->life_support
                       + ship->solar_panels)) {
     
-    bool nice = government_has_hint(g, G_IS_NICE);
-    /* "nice" governments prefer to keep success 100%;
-     * others build habitation first (for score?)  (Thanks Massimo.)
-     */
-
     type =
       (ship->habitation==0)   ? SSHIP_PLACE_HABITATION :
       (ship->life_support==0) ? SSHIP_PLACE_LIFE_SUPPORT :
@@ -56,11 +50,10 @@
                               ? SSHIP_PLACE_SOLAR_PANELS :
       (ship->life_support<ship->habitation)
                               ? SSHIP_PLACE_LIFE_SUPPORT :
-      (nice && (ship->life_support <= ship->habitation)
+      ((ship->life_support <= ship->habitation)
        && (ship->solar_panels*2 >= ship->habitation + ship->life_support + 1))
                               ? SSHIP_PLACE_LIFE_SUPPORT :
-      (nice)                  ? SSHIP_PLACE_SOLAR_PANELS :
-                                SSHIP_PLACE_HABITATION;
+                                SSHIP_PLACE_SOLAR_PANELS;
 
     if (type == SSHIP_PLACE_HABITATION) {
       num = ship->habitation + 1;
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.393
diff -u -r1.393 packhand.c
--- client/packhand.c   2 Aug 2004 16:59:14 -0000       1.393
+++ client/packhand.c   12 Aug 2004 07:34:24 -0000
@@ -1767,7 +1767,6 @@
 static bool spaceship_autoplace(struct player *pplayer,
                               struct player_spaceship *ship)
 {
-  struct government *g = get_gov_pplayer(pplayer);
   int i, num;
   enum spaceship_place_type type;
   
@@ -1776,8 +1775,6 @@
     /* "nice" governments prefer to keep success 100%;
      * others build habitation first (for score?)  (Thanks Massimo.)
      */
-    bool nice = government_has_hint(g, G_IS_NICE);
-
     type =
       (ship->habitation==0)   ? SSHIP_PLACE_HABITATION :
       (ship->life_support==0) ? SSHIP_PLACE_LIFE_SUPPORT :
@@ -1789,11 +1786,10 @@
                               ? SSHIP_PLACE_SOLAR_PANELS :
       (ship->life_support<ship->habitation)
                               ? SSHIP_PLACE_LIFE_SUPPORT :
-      (nice && (ship->life_support <= ship->habitation)
+      ((ship->life_support <= ship->habitation)
        && (ship->solar_panels*2 >= ship->habitation + ship->life_support + 1))
                               ? SSHIP_PLACE_LIFE_SUPPORT :
-      (nice)                  ? SSHIP_PLACE_SOLAR_PANELS :
-                                SSHIP_PLACE_HABITATION;
+                                SSHIP_PLACE_SOLAR_PANELS;
 
     if (type == SSHIP_PLACE_HABITATION) {
       num = ship->habitation + 1;
@@ -2530,7 +2526,6 @@
   gov->waste_max_distance_cap = p->waste_max_distance_cap;
   
   gov->flags               = p->flags;
-  gov->hints               = p->hints;
   gov->num_ruler_titles    = p->num_ruler_titles;
     
   sz_strlcpy(gov->name, p->name);
Index: common/government.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.c,v
retrieving revision 1.43
diff -u -r1.43 government.c
--- common/government.c 25 Jun 2004 23:43:01 -0000      1.43
+++ common/government.c 12 Aug 2004 07:34:24 -0000
@@ -66,9 +66,6 @@
   "Fanatic_Troops", "No_Unhappy_Citizens", "Convert_Tithes_To_Money",
   "Reduced_Research"
 };
-static const char *hint_names[] = {
-  "Is_Nice", "Favors_Growth"
-};
 
 /***************************************************************
   Convert flag names to enum; case insensitive;
@@ -99,34 +96,6 @@
 }
 
 /***************************************************************
-  Convert hint names to enum; case insensitive;
-  returns G_LAST_HINT if can't match.
-***************************************************************/
-enum government_hint_id government_hint_from_str(const char *s)
-{
-  enum government_hint_id i;
-
-  assert(ARRAY_SIZE(hint_names) == G_LAST_HINT);
-  
-  for(i=G_FIRST_HINT; i<G_LAST_HINT; i++) {
-    if (mystrcasecmp(hint_names[i], s)==0) {
-      return i;
-    }
-  }
-  return G_LAST_HINT;
-}
-
-/***************************************************************
-...
-***************************************************************/
-bool government_has_hint(const struct government *gov,
-                       enum government_hint_id hint)
-{
-  assert(hint>=G_FIRST_HINT && hint<G_LAST_HINT);
-  return TEST_BIT(gov->hints, hint);
-}
-
-/***************************************************************
 ...
 ***************************************************************/
 struct government *find_government_by_name(const char *name)
Index: common/government.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.h,v
retrieving revision 1.28
diff -u -r1.28 government.h
--- common/government.h 14 Jun 2004 23:43:08 -0000      1.28
+++ common/government.h 12 Aug 2004 07:34:24 -0000
@@ -75,7 +75,6 @@
   char  graphic_str[MAX_LEN_NAME];
   char  graphic_alt[MAX_LEN_NAME];
   int   required_tech;         /* tech required to change to this gov */
-  int   subgoal;               /* for AI; another government or -1 */
 
   struct ruler_title *ruler_titles;
   int   num_ruler_titles;
@@ -147,9 +146,6 @@
   /* other flags: bits in enum government_flag_id order,
      use government_has_flag() to access */
   int   flags;
-  /* other hints: bits in enum government_hint_id order,
-     use government_has_hint() to access */
-  int   hints;
 
   struct Sprite *sprite;
   
@@ -181,9 +177,6 @@
 enum government_flag_id government_flag_from_str(const char *s);
 bool government_has_flag(const struct government *gov,
                        enum government_flag_id flag);
-enum government_hint_id government_hint_from_str(const char *s);
-bool government_has_hint(const struct government *gov,
-                       enum government_hint_id hint);
 
 int get_government_max_rate(int type);
 int get_government_civil_war_prob(int type);
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.37
diff -u -r1.37 packets.def
--- common/packets.def  11 Aug 2004 18:49:29 -0000      1.37
+++ common/packets.def  12 Aug 2004 07:34:25 -0000
@@ -1069,7 +1069,6 @@
   UINT8 waste_max_distance_cap;
       
   UINT16 flags;
-  UINT8 hints;
       
   UINT8 num_ruler_titles;
        
Index: data/default/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/governments.ruleset,v
retrieving revision 1.22
diff -u -r1.22 governments.ruleset
--- data/default/governments.ruleset    14 Aug 2003 21:17:58 -0000      1.22
+++ data/default/governments.ruleset    12 Aug 2004 07:34:27 -0000
@@ -46,9 +46,6 @@
 ;               should be a standard tag if preferred is not;
 ;              otherwise may be "-"
 ; flags       = special effects; see government.c for strings
-; hints       = hints to the AI about how to use / behave with government
-; subgoal     = another government name or "-"; if main gov is nation or 
-;              AI goal government, aim for subgoal first.
 
 ; martial_law_max  = maximum number of units which can enforce martial law
 ;                   in the city
@@ -117,8 +114,6 @@
 graphic     = "gov.anarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -196,8 +191,6 @@
 graphic     = "gov.despotism"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -275,8 +268,6 @@
 graphic     = "gov.monarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 3
 martial_law_per  = 1
@@ -353,8 +344,6 @@
 graphic     = "gov.communism"
 graphic_alt = "-"
 flags       = "Build_Veteran_Diplomats", "Inspires_Partisans"
-hints       = "Favors_Growth"
-subgoal            = "Monarchy"
 
 martial_law_max  = 3
 martial_law_per  = 2
@@ -439,8 +428,6 @@
 graphic     = "gov.republic"
 graphic_alt = "-"
 flags       = "Has_Senate", "Rapture_City_Growth"
-hints       = "Is_Nice"
-subgoal            = "Monarchy"
 
 martial_law_max  = 0
 martial_law_per  = 0
@@ -528,8 +515,6 @@
 graphic_alt = "-"
 flags       = "Has_Senate", "Revolution_When_Unhappy", 
               "Inspires_Partisans", "Unbribable", "Rapture_City_Growth"
-hints       = "Is_Nice" 
-subgoal            = "Republic"
 
 martial_law_max  = 0
 martial_law_per  = 0
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.183
diff -u -r1.183 ruleset.c
--- server/ruleset.c    24 Jul 2004 12:26:06 -0000      1.183
+++ server/ruleset.c    12 Aug 2004 07:34:29 -0000
@@ -1872,26 +1872,6 @@
     free(slist);
   } government_iterate_end;
 
-  /* hints: */
-  government_iterate(g) {
-    g->hints = 0;
-    slist = secfile_lookup_str_vec(file, &nval, "%s.hints", sec[g->index]);
-    for(j=0; j<nval; j++) {
-      char *sval = slist[j];
-      enum government_hint_id hint = government_hint_from_str(sval);
-      if (strcmp(sval, "-") == 0) {
-        continue;
-      }
-      if (hint == G_LAST_HINT) {
-        freelog(LOG_FATAL, "government %s has unknown hint %s", g->name, sval);
-        exit(EXIT_FAILURE);
-      } else {
-        g->hints |= (1<<hint);
-      }
-    }
-    free(slist);
-  } government_iterate_end;
-
   /* titles */
   government_iterate(g) {
     int i = g->index;
@@ -1908,24 +1888,6 @@
               secfile_lookup_str(file, "%s.ruler_female_title", sec[i]));
   } government_iterate_end;
 
-  /* subgoals: */
-  government_iterate(g) {
-    char *sval;
-    sval = secfile_lookup_str(file, "%s.subgoal", sec[g->index]);
-    if (strcmp(sval, "-")==0) {
-      g->subgoal = -1;
-    } else {
-      struct government *subgov = find_government_by_name(sval);
-      if (!subgov) {
-       freelog(LOG_ERROR, "Bad subgoal government \"%s\" for gov \"%s\" (%s)",
-               sval, g->name, filename);
-      } else {
-       g->subgoal = subgov - governments;
-      }
-    }
-    freelog(LOG_DEBUG, "%s subgoal %d", g->name, g->subgoal);
-  } government_iterate_end;
-    
   /* ai tech_hints: */
   j = -1;
   while((c = secfile_lookup_str_default(file, NULL,
@@ -3057,7 +3019,6 @@
     gov.waste_max_distance_cap = g->waste_max_distance_cap;
         
     gov.flags = g->flags;
-    gov.hints = g->hints;
     gov.num_ruler_titles = g->num_ruler_titles;
 
     sz_strlcpy(gov.name, g->name_orig);
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.176
diff -u -r1.176 capstr.c
--- common/capstr.c     11 Aug 2004 18:49:29 -0000      1.176
+++ common/capstr.c     12 Aug 2004 07:37:00 -0000
@@ -78,7 +78,7 @@
                    "+change_production +tilespec1 +no_earth +trans " \
                    "+want_hack invasions bombard +killstack2 spec +spec2 " \
                    "+city_map startunits +turn_last_built +happyborders " \
-                   "+connid +love2"
+                   "+connid +love2 +hints"
 
 /* "+1.14.delta" is the new delta protocol for 1.14.0-dev.
  *
@@ -137,6 +137,8 @@
  * 
  * "love" means that we show the AI love for you in the client
  * "love2" includes a bugfix
+ * 
+ * "hints" removes useless AI hints from governments
  */
 
 void init_our_capability(void)
Index: data/civ1/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/governments.ruleset,v
retrieving revision 1.19
diff -u -r1.19 governments.ruleset
--- data/civ1/governments.ruleset       22 Sep 2003 15:19:41 -0000      1.19
+++ data/civ1/governments.ruleset       12 Aug 2004 07:37:01 -0000
@@ -47,9 +47,6 @@
 ;               should be a standard tag if preferred is not;
 ;              otherwise may be "-"
 ; flags       = special effects; see government.c for strings
-; hints       = hints to the AI about how to use / behave with government
-; subgoal     = another government name or "-"; if main gov is nation or 
-;              AI goal government, aim for subgoal first.
 
 ; martial_law_max  = maximum number of units which can enforce martial law
 ;                   in the city
@@ -118,8 +115,6 @@
 graphic     = "gov.anarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -197,8 +192,6 @@
 graphic     = "gov.despotism"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -274,8 +267,6 @@
 graphic     = "gov.monarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -349,8 +340,6 @@
 graphic     = "gov.communism"
 graphic_alt = "-"
 flags       = "Build_Veteran_Diplomats"
-hints       = "Favors_Growth"
-subgoal            = "Monarchy"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -432,8 +421,6 @@
 graphic     = "gov.republic"
 graphic_alt = "-"
 flags       = "Has_Senate", "Rapture_City_Growth"
-hints       = "Is_Nice"
-subgoal            = "Monarchy"
 
 martial_law_max  = 0
 martial_law_per  = 0
@@ -518,8 +505,6 @@
 graphic     = "gov.democracy"
 graphic_alt = "-"
 flags       = "Has_Senate", "Revolution_When_Unhappy", "Rapture_City_Growth"
-hints       = "Is_Nice"
-subgoal            = "Republic"
 
 martial_law_max  = 0
 martial_law_per  = 0
Index: data/civ2/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/governments.ruleset,v
retrieving revision 1.27
diff -u -r1.27 governments.ruleset
--- data/civ2/governments.ruleset       5 May 2003 12:11:13 -0000       1.27
+++ data/civ2/governments.ruleset       12 Aug 2004 07:37:01 -0000
@@ -45,9 +45,6 @@
 ;               should be a standard tag if preferred is not;
 ;              otherwise may be "-"
 ; flags       = special effects; see government.c for strings
-; hints       = hints to the AI about how to use / behave with government
-; subgoal     = another government name or "-"; if main gov is nation or 
-;              AI goal government, aim for subgoal first.
 
 ; martial_law_max  = maximum number of units which can enforce martial law
 ;                   in the city
@@ -116,8 +113,6 @@
 graphic     = "gov.anarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -195,8 +190,6 @@
 graphic     = "gov.despotism"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -274,8 +267,6 @@
 graphic     = "gov.monarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 3
 martial_law_per  = 1
@@ -352,8 +343,6 @@
 graphic     = "gov.communism"
 graphic_alt = "-"
 flags       = "Build_Veteran_Diplomats", "Inspires_Partisans"
-hints       = "Favors_Growth"
-subgoal            = "Monarchy"
 
 martial_law_max  = 3
 martial_law_per  = 2
@@ -438,8 +427,6 @@
 graphic_alt = "-"
 flags       = "No_Unhappy_Citizens", "Convert_Tithes_To_Money", 
               "Reduced_Research", "Fanatic_Troops"
-hints       = "Favors_Growth"
-subgoal            = "Communism"   ; ??
 
 martial_law_max  = 0
 martial_law_per  = 0
@@ -526,8 +513,6 @@
 graphic     = "gov.republic"
 graphic_alt = "-"
 flags       = "Has_Senate", "Rapture_City_Growth"
-hints       = "Is_Nice"
-subgoal            = "Monarchy"
 
 martial_law_max  = 0
 martial_law_per  = 0
@@ -616,8 +601,6 @@
 graphic_alt = "-"
 flags       = "Has_Senate", "Revolution_When_Unhappy", 
               "Inspires_Partisans", "Unbribable", "Rapture_City_Growth"
-hints       = "Is_Nice"
-subgoal            = "Republic"
 
 martial_law_max  = 0
 martial_law_per  = 0
Index: data/history/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/governments.ruleset,v
retrieving revision 1.5
diff -u -r1.5 governments.ruleset
--- data/history/governments.ruleset    10 Mar 2003 16:32:30 -0000      1.5
+++ data/history/governments.ruleset    12 Aug 2004 07:37:01 -0000
@@ -46,9 +46,6 @@
 ;               should be a standard tag if preferred is not;
 ;              otherwise may be "-"
 ; flags       = special effects; see government.c for strings
-; hints       = hints to the AI about how to use / behave with government
-; subgoal     = another government name or "-"; if main gov is nation or 
-;              AI goal government, aim for subgoal first.
 
 ; martial_law_max  = maximum number of units which can enforce martial law
 ;                   in the city
@@ -117,8 +114,6 @@
 graphic     = "gov.anarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -196,8 +191,6 @@
 graphic     = "gov.despotism"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
@@ -275,8 +268,6 @@
 graphic     = "gov.monarchy"
 graphic_alt = "-"
 flags       = "-"
-hints       = "Favors_Growth"
-subgoal            = "-"
 
 martial_law_max  = 3
 martial_law_per  = 1
@@ -353,8 +344,6 @@
 graphic     = "gov.communism"
 graphic_alt = "-"
 flags       = "Build_Veteran_Diplomats", "Inspires_Partisans"
-hints       = "Favors_Growth"
-subgoal            = "Monarchy"
 
 martial_law_max  = 3
 martial_law_per  = 2
@@ -438,8 +427,6 @@
 graphic     = "gov.republic"
 graphic_alt = "-"
 flags       = "Has_Senate", "Rapture_City_Growth"
-hints       = "Is_Nice"
-subgoal            = "Monarchy"
 
 martial_law_max  = 0
 martial_law_per  = 0
@@ -527,8 +514,6 @@
 graphic_alt = "-"
 flags       = "Has_Senate", "Revolution_When_Unhappy", 
               "Inspires_Partisans", "Unbribable", "Rapture_City_Growth"
-hints       = "Is_Nice" 
-subgoal            = "Republic"
 
 martial_law_max  = 0
 martial_law_per  = 0

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9683) Remove AI hints from govts, Per I. Mathisen <=