Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#7129) server-side CMA uses bad parameters
Home

[Freeciv-Dev] (PR#7129) server-side CMA uses bad parameters

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7129) server-side CMA uses bad parameters
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Mar 2004 17:48:58 -0800
Reply-to: rt@xxxxxxxxxxx

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

This updated patch adjusts the parameters some more.  Now it should work
quite well for human players.

For AI players there is no way for the AI to adjust the priorities.  But
since the current method is already broken, this is okay.  A comment
describes how to change this.  Eventually I think the AI and human cases
will probably be entirely separate.

jason

Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.245
diff -u -r1.245 cityturn.c
--- server/cityturn.c   25 Feb 2004 20:23:50 -0000      1.245
+++ server/cityturn.c   11 Mar 2004 01:47:11 -0000
@@ -151,7 +151,6 @@
   struct cm_parameter cmp;
   struct cm_result cmr;
   struct player *pplayer = city_owner(pcity);
-  struct ai_data *ai = ai_data_get(pplayer);
 
   /* HACK: make sure everything is up-to-date before continuing.  This may
    * result in recursive calls to auto_arrange_workers, but it's better
@@ -169,26 +168,27 @@
   cmp.allow_specialists = TRUE;
   cmp.factor_target = FT_SURPLUS;
 
-  /* WAGs. These are set for both AI and humans.
-   * FIXME: Adjust & remove kludges */
+  /* We used to look at pplayer->ai.xxx_priority to determine the values
+   * to be used here.  However that doesn't at all because those values
+   * are on a different scale.  Later the ai may wish to adjust its
+   * priorities - this should be done via a separate set of variables. */
   if (pcity->size > 1) {
-    cmp.factor[FOOD] = ai->food_priority - 9;
+    cmp.factor[FOOD] = 10;
   } else {
-    /* Growing to size 2 is priority #1, since then we have the
-     * option of making settlers. */
+    /* Growing to size 2 is the highest priority. */
     cmp.factor[FOOD] = 20;
   }
-  cmp.factor[SHIELD] = ai->shield_priority - 7;
-  cmp.factor[TRADE] = 10;
-  cmp.factor[GOLD] = ai->gold_priority - 11;
-  cmp.factor[LUXURY] = ai->luxury_priority;
-  cmp.factor[SCIENCE] = ai->science_priority + 3;
-  cmp.happy_factor = ai->happy_priority - 1;
+  cmp.factor[SHIELD] = 5;
+  cmp.factor[TRADE] = 0; /* Trade only provides gold/science. */
+  cmp.factor[GOLD] = 2;
+  cmp.factor[LUXURY] = 0; /* Luxury only influences happiness. */
+  cmp.factor[SCIENCE] = 2;
+  cmp.happy_factor = 0;
 
   cmp.minimal_surplus[FOOD] = 1;
   cmp.minimal_surplus[SHIELD] = 1;
   cmp.minimal_surplus[TRADE] = 0;
-  cmp.minimal_surplus[GOLD] = 0;
+  cmp.minimal_surplus[GOLD] = -FC_INFINITY;
   cmp.minimal_surplus[LUXURY] = 0;
   cmp.minimal_surplus[SCIENCE] = 0;
 
@@ -196,19 +196,26 @@
 
   if (!cmr.found_a_valid) {
     if (!pplayer->ai.control) {
-      /* 
-       * If we can't get a resonable result force a disorder.
-       */
-      cmp.allow_disorder = TRUE;
-      cmp.allow_specialists = FALSE;
-      cmp.minimal_surplus[FOOD] = -FC_INFINITY;
-      cmp.minimal_surplus[SHIELD] = -FC_INFINITY;
-      cmp.minimal_surplus[TRADE] = -FC_INFINITY;
-      cmp.minimal_surplus[GOLD] = -FC_INFINITY;
-      cmp.minimal_surplus[LUXURY] = -FC_INFINITY;
-      cmp.minimal_surplus[SCIENCE] = -FC_INFINITY;
-
+      /* Drop surpluses and try again. */
+      cmp.minimal_surplus[FOOD] = 0;
+      cmp.minimal_surplus[SHIELD] = 0;
       cm_query_result(pcity, &cmp, &cmr);
+
+      if (!cmr.found_a_valid) {
+       /* 
+        * If we can't get a resonable result force a disorder.
+        */
+       cmp.allow_disorder = TRUE;
+       cmp.allow_specialists = FALSE;
+       cmp.minimal_surplus[FOOD] = -FC_INFINITY;
+       cmp.minimal_surplus[SHIELD] = -FC_INFINITY;
+       cmp.minimal_surplus[TRADE] = -FC_INFINITY;
+       cmp.minimal_surplus[GOLD] = -FC_INFINITY;
+       cmp.minimal_surplus[LUXURY] = -FC_INFINITY;
+       cmp.minimal_surplus[SCIENCE] = -FC_INFINITY;
+
+       cm_query_result(pcity, &cmp, &cmr);
+      }
     } else {
       cmp.minimal_surplus[FOOD] = 0;
       cmp.minimal_surplus[SHIELD] = 0;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7129) server-side CMA uses bad parameters, Jason Short <=