Complete.Org: Mailing Lists: Archives: freeciv-ai: July 2004:
[freeciv-ai] Re: (PR#9247) cm shouldn't count waste as a good thing
Home

[freeciv-ai] Re: (PR#9247) cm shouldn't count waste as a good thing

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#9247) cm shouldn't count waste as a good thing
From: "Benoit Hudson" <bh@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Jul 2004 15:44:20 -0700
Reply-to: rt@xxxxxxxxxxx

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

On Tue, Jul 13, 2004 at 02:18:32PM -0700, Jason Short wrote:
> > Can someone verify my logic is correct here?  Am I missing something?
>
> Yes, I'm missing something.  The production values are AFAICT only used
> for sanity checking.  And if the waste/corruption values are removed the
> sanity check fails.  IMO this is a bug; these values should be dropped.
>  But I don't know enough to make changes here yet.
>
> In any case it is the surplus (or sometimes the surplus plus a constant
> amount, which is the same thing (!?!?)) that is used in the calculation
> of goodness of a combination.  So the patch was in error.

I don't know about the city struct, but the CM assumes that "production"
is what you get from tiles + factory + power plant + mfg plant.
"surplus" is "production" - waste and usage from units.
The copy_stats function indicates that the city struct has a different
idea.

Production is not used; it's not clear to me why the CM should care
about it at all.

While we're at removing things, we could remove the factor_target too,
since (a) no code uses FT_EXTRA; (b) it shouldn't change the results
anyway; (c) it does change the results because the current 'base = min -
surplus' logic is wrong: higher surplus right now means lower score!

Attached patch removes those and also merges some duplicated code
between cm.c and cma_core.c (only that duplicated code that is
affected).

        -- Benoît

Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.90
diff -b -u -p -r1.90 aihand.c
--- ai/aihand.c 12 Jul 2004 20:56:07 -0000      1.90
+++ ai/aihand.c 13 Jul 2004 22:42:11 -0000
@@ -157,7 +157,6 @@ static void ai_manage_taxes(struct playe
     cmp.require_happy = TRUE;    /* note this one */
     cmp.allow_disorder = FALSE;
     cmp.allow_specialists = TRUE;
-    cmp.factor_target = FT_SURPLUS;
     cmp.factor[FOOD] = 20;
     cmp.minimal_surplus[GOLD] = -FC_INFINITY;
 
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.99
diff -b -u -p -r1.99 options.c
--- client/options.c    25 Jun 2004 23:35:55 -0000      1.99
+++ client/options.c    13 Jul 2004 22:42:11 -0000
@@ -640,8 +640,6 @@ static void load_cma_preset(struct secti
   }
   parameter.require_happy =
       secfile_lookup_bool_default(file, FALSE, "cma.preset%d.reqhappy", inx);
-  parameter.factor_target =
-      secfile_lookup_int_default(file, 0, "cma.preset%d.factortarget", inx);
   parameter.happy_factor =
       secfile_lookup_int_default(file, 0, "cma.preset%d.happyfactor", inx);
   parameter.allow_disorder = FALSE;
@@ -668,8 +666,6 @@ static void save_cma_preset(struct secti
   }
   secfile_insert_bool(file, pparam->require_happy,
                      "cma.preset%d.reqhappy", inx);
-  secfile_insert_int(file, pparam->factor_target,
-                    "cma.preset%d.factortarget", inx);
   secfile_insert_int(file, pparam->happy_factor,
                     "cma.preset%d.happyfactor", inx);
 }
Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.54
diff -b -u -p -r1.54 cma_core.c
--- client/agents/cma_core.c    13 Jul 2004 18:16:54 -0000      1.54
+++ client/agents/cma_core.c    13 Jul 2004 22:42:11 -0000
@@ -66,7 +66,7 @@
 #define SHOW_APPLY_RESULT_ON_SERVER_ERRORS              FALSE
 #define ALWAYS_APPLY_AT_SERVER                          FALSE
 
-#define SAVED_PARAMETER_SIZE                           29
+#define SAVED_PARAMETER_SIZE                           28
 
 /*
  * Misc statistic to analyze performance.
@@ -121,13 +121,6 @@ static bool results_are_equal(struct cit
   T(specialists[SP_SCIENTIST]);
   T(specialists[SP_TAXMAN]);
 
-  T(production[FOOD]);
-  T(production[SHIELD]);
-  T(production[TRADE]);
-  T(production[GOLD]);
-  T(production[LUXURY]);
-  T(production[SCIENCE]);
-
   T(surplus[FOOD]);
   T(surplus[SHIELD]);
   T(surplus[TRADE]);
@@ -148,119 +141,7 @@ static bool results_are_equal(struct cit
 
 #undef T
 
-/****************************************************************************
- Print the current state of the given city via
- freelog(LOG_NORMAL,...).
-*****************************************************************************/
-static void print_city(struct city *pcity)
-{
-  freelog(LOG_NORMAL, "print_city(city='%s'(id=%d))",
-         pcity->name, pcity->id);
-  freelog(LOG_NORMAL,
-         "  size=%d, entertainers=%d, scientists=%d, taxmen=%d",
-         pcity->size, pcity->specialists[SP_ELVIS],
-         pcity->specialists[SP_SCIENTIST],
-         pcity->specialists[SP_TAXMAN]);
-  freelog(LOG_NORMAL, "  workers at:");
-  my_city_map_iterate(pcity, x, y) {
-    if (pcity->city_map[x][y] == C_TILE_WORKER) {
-      freelog(LOG_NORMAL, "    (%2d,%2d)", x, y);
-    }
-  } my_city_map_iterate_end;
-
-  freelog(LOG_NORMAL, "  food    = %3d (%+3d)",
-         pcity->food_prod, pcity->food_surplus);
-  freelog(LOG_NORMAL, "  shield  = %3d (%+3d)",
-         pcity->shield_prod + pcity->shield_waste, pcity->shield_prod);
-  freelog(LOG_NORMAL, "  trade   = %3d (%+3d)",
-         pcity->trade_prod + pcity->corruption, pcity->trade_prod);
-
-  freelog(LOG_NORMAL, "  gold    = %3d (%+3d)", pcity->tax_total,
-         city_gold_surplus(pcity));
-  freelog(LOG_NORMAL, "  luxury  = %3d", pcity->luxury_total);
-  freelog(LOG_NORMAL, "  science = %3d", pcity->science_total);
-}
 
-/****************************************************************************
- Print the given result via freelog(LOG_NORMAL,...). The given result
- has to be a result for the given city.
-*****************************************************************************/
-static void print_result(struct city *pcity,
-                        const struct cm_result *const result)
-{
-  int y, i, worker = count_worker(pcity, result);
-
-  freelog(LOG_NORMAL, "print_result(result=%p)", result);
-  freelog(LOG_NORMAL,
-         "print_result:  found_a_valid=%d disorder=%d happy=%d",
-         result->found_a_valid, result->disorder, result->happy);
-#if UNUSED
-  freelog(LOG_NORMAL, "print_result:  workers at:");
-  my_city_map_iterate(pcity, x, y) {
-    if (result->worker_positions_used[x][y]) {
-      freelog(LOG_NORMAL, "print_result:    (%2d,%2d)", x, y);
-    }
-  } my_city_map_iterate_end;
-#endif
-
-  for (y = 0; y < CITY_MAP_SIZE; y++) {
-    char line[CITY_MAP_SIZE + 1];
-    int x;
-
-    line[CITY_MAP_SIZE] = 0;
-
-    for (x = 0; x < CITY_MAP_SIZE; x++) {
-      if (!is_valid_city_coords(x, y)) {
-       line[x] = '-';
-      } else if (is_city_center(x, y)) {
-       line[x] = 'c';
-      } else if (result->worker_positions_used[x][y]) {
-       line[x] = 'w';
-      } else {
-       line[x] = '.';
-      }
-    }
-    freelog(LOG_NORMAL, "print_result: %s", line);
-  }
-
-  freelog(LOG_NORMAL,
-         "print_result:  people: W/E/S/T %d/%d/%d/%d",
-         worker, result->specialists[SP_ELVIS],
-         result->specialists[SP_SCIENTIST], result->specialists[SP_TAXMAN]);
-
-  for (i = 0; i < NUM_STATS; i++) {
-    freelog(LOG_NORMAL,
-           "print_result:  %10s production=%d surplus=%d",
-           cm_get_stat_name(i), result->production[i],
-           result->surplus[i]);
-  }
-}
-
-/****************************************************************************
- Copy the current production stats and happy status of the given city
- to the result.
-*****************************************************************************/
-static void copy_stats(struct city *pcity, struct cm_result *result)
-{
-  result->production[FOOD] = pcity->food_prod;
-  result->production[SHIELD] = pcity->shield_prod + pcity->shield_waste;
-  result->production[TRADE] = pcity->trade_prod + pcity->corruption;
-
-  result->surplus[FOOD] = pcity->food_surplus;
-  result->surplus[SHIELD] = pcity->shield_surplus;
-  result->surplus[TRADE] = pcity->trade_prod;
-
-  result->production[GOLD] = pcity->tax_total;
-  result->production[LUXURY] = pcity->luxury_total;
-  result->production[SCIENCE] = pcity->science_total;
-
-  result->surplus[GOLD] = city_gold_surplus(pcity);
-  result->surplus[LUXURY] = result->production[LUXURY];
-  result->surplus[SCIENCE] = result->production[SCIENCE];
-
-  result->disorder = city_unhappy(pcity);
-  result->happy = city_happy(pcity);
-}
 
 /****************************************************************************
  Copy the current city state (citizen assignment, production stats and
@@ -292,7 +173,7 @@ static void get_current_as_result(struct
 
   result->found_a_valid = TRUE;
 
-  copy_stats(pcity, result);
+  cm_copy_result_from_city(pcity, result);
 }
 
 /****************************************************************************
@@ -356,8 +237,7 @@ static bool apply_result_on_server(struc
       (worker + result->specialists[SP_ELVIS]
        + result->specialists[SP_SCIENTIST]
        + result->specialists[SP_TAXMAN])) {
-    print_city(pcity);
-    print_result(pcity, result);
+    cm_print_result(pcity, result, TRUE);
     assert(0);
   }
 
@@ -448,9 +328,9 @@ static bool apply_result_on_server(struc
 
     if (SHOW_APPLY_RESULT_ON_SERVER_ERRORS) {
       freelog(LOG_NORMAL, "expected");
-      print_result(pcity, result);
+      cm_print_result(pcity, result, FALSE);
       freelog(LOG_NORMAL, "got");
-      print_result(pcity, &current_state);
+      cm_print_result(pcity, &current_state, FALSE);
     }
   }
   return success;
@@ -713,7 +593,6 @@ bool cma_get_parameter(enum attr_city at
   }
 
   dio_get_sint16(&din, &parameter->happy_factor);
-  dio_get_uint8(&din, (int *) &parameter->factor_target);
   dio_get_bool8(&din, &parameter->require_happy);
   /* These options are only for server-AI use. */
   parameter->allow_disorder = FALSE;
@@ -742,7 +621,6 @@ void cma_set_parameter(enum attr_city at
   }
 
   dio_put_sint16(&dout, parameter->happy_factor);
-  dio_put_uint8(&dout, (int) parameter->factor_target);
   dio_put_bool8(&dout, parameter->require_happy);
 
   assert(dio_output_used(&dout) == SAVED_PARAMETER_SIZE);
Index: client/agents/cma_fec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.c,v
retrieving revision 1.20
diff -b -u -p -r1.20 cma_fec.c
--- client/agents/cma_fec.c     29 May 2004 20:34:31 -0000      1.20
+++ client/agents/cma_fec.c     13 Jul 2004 22:42:11 -0000
@@ -128,7 +128,6 @@ void cmafec_get_fe_parameter(struct city
       dest->require_happy = FALSE;
       dest->allow_disorder = FALSE;
       dest->allow_specialists = TRUE;
-      dest->factor_target = FT_SURPLUS;
 
       cmafec_set_fe_parameter(pcity, dest);
     }
@@ -345,19 +344,13 @@ const char *cmafec_get_result_descr(stru
     for (j = 0; j < RESULT_COLUMNS; j++)
       my_snprintf(buf[j], BUFFER_SIZE, "---");
   } else {
-    my_snprintf(buf[0], BUFFER_SIZE, "%3d(%+3d)",
-               result->production[FOOD], result->surplus[FOOD]);
-    my_snprintf(buf[1], BUFFER_SIZE, "%3d(%+3d)",
-               result->production[SHIELD], result->surplus[SHIELD]);
-    my_snprintf(buf[2], BUFFER_SIZE, "%3d(%+3d)",
-               result->production[TRADE], result->surplus[TRADE]);
-
-    my_snprintf(buf[3], BUFFER_SIZE, "%3d(%+3d)",
-               result->production[GOLD], result->surplus[GOLD]);
-    my_snprintf(buf[4], BUFFER_SIZE, "%3d(%+3d)",
-               result->production[LUXURY], result->surplus[LUXURY]);
-    my_snprintf(buf[5], BUFFER_SIZE, "%3d(%+3d)",
-               result->production[SCIENCE], result->surplus[SCIENCE]);
+    my_snprintf(buf[0], BUFFER_SIZE, "%3d", result->surplus[FOOD]);
+    my_snprintf(buf[1], BUFFER_SIZE, "%3d", result->surplus[SHIELD]);
+    my_snprintf(buf[2], BUFFER_SIZE, "%3d", result->surplus[TRADE]);
+
+    my_snprintf(buf[3], BUFFER_SIZE, "%3d", result->surplus[GOLD]);
+    my_snprintf(buf[4], BUFFER_SIZE, "%3d", result->surplus[LUXURY]);
+    my_snprintf(buf[5], BUFFER_SIZE, "%3d", result->surplus[SCIENCE]);
 
     my_snprintf(buf[6], BUFFER_SIZE, "%d/%d/%d/%d%s",
                pcity->size -
Index: client/gui-gtk/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cma_fe.c,v
retrieving revision 1.21
diff -b -u -p -r1.21 cma_fe.c
--- client/gui-gtk/cma_fe.c     5 May 2004 20:39:15 -0000       1.21
+++ client/gui-gtk/cma_fe.c     13 Jul 2004 22:42:11 -0000
@@ -673,7 +673,6 @@ static void hscale_changed(GtkAdjustment
     param.minimal_surplus[i] = (int) (pdialog->minimal_surplus[i]->value);
     param.factor[i] = (int) (pdialog->factor[i]->value);
   }
-  param.factor_target = FT_SURPLUS;
   param.require_happy =
       (GTK_TOGGLE_BUTTON(pdialog->happy_button)->active ? 1 : 0);
   param.happy_factor = (int) (pdialog->factor[NUM_STATS]->value);
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.31
diff -b -u -p -r1.31 cm.c
--- common/aicore/cm.c  13 Jul 2004 18:26:32 -0000      1.31
+++ common/aicore/cm.c  13 Jul 2004 22:42:11 -0000
@@ -163,7 +163,7 @@ static struct {
 
   struct secondary_stat {
     bool is_valid;
-    short int production, surplus;
+    short int surplus;
   } *secondary_stats;
   struct city_status {
     bool is_valid, disorder, happy;
@@ -236,7 +236,7 @@ struct tile_stats {
  Returns the number of workers of the given result. The given result
  has to be a result for the given city.
 *****************************************************************************/
-static int count_worker(struct city *pcity,
+static int count_worker(const struct city *pcity,
                        const struct cm_result *const result)
 {
   int worker = 0;
@@ -350,7 +350,7 @@ static bool is_valid_result(const struct
  Print the current state of the given city via
  freelog(LOG_NORMAL,...).
 *****************************************************************************/
-static void print_city(struct city *pcity)
+static void print_city(const struct city *pcity)
 {
   freelog(LOG_NORMAL, "print_city(city='%s'(id=%d))",
          pcity->name, pcity->id);
@@ -382,11 +382,16 @@ static void print_city(struct city *pcit
  Print the given result via freelog(LOG_NORMAL,...). The given result
  has to be a result for the given city.
 *****************************************************************************/
-static void print_result(struct city *pcity,
-                        const struct cm_result *const result)
+void cm_print_result(const struct city *pcity,
+        const struct cm_result *const result,
+        bool do_print_city)
 {
   int y, i, worker = count_worker(pcity, result);
 
+  if(do_print_city) {
+      print_city(pcity);
+  }
+
   freelog(LOG_NORMAL, "print_result(result=%p)", result);
   freelog(LOG_NORMAL,
          "print_result:  found_a_valid=%d disorder=%d happy=%d",
@@ -428,9 +433,8 @@ static void print_result(struct city *pc
 
   for (i = 0; i < NUM_STATS; i++) {
     freelog(LOG_NORMAL,
-           "print_result:  %10s production=%d surplus=%d",
-           cm_get_stat_name(i), result->production[i],
-           result->surplus[i]);
+           "print_result:  %10s surplus=%d",
+           cm_get_stat_name(i), result->surplus[i]);
   }
 }
 
@@ -460,23 +464,16 @@ static void print_combination(struct cit
  Copy the current production stats and happy status of the given city
  to the result.
 *****************************************************************************/
-static void copy_stats(struct city *pcity, struct cm_result *result)
+void cm_copy_result_from_city(const struct city *pcity,
+        struct cm_result *result)
 {
-  result->production[FOOD] = pcity->food_prod;
-  result->production[SHIELD] = pcity->shield_prod;
-  result->production[TRADE] = pcity->trade_prod;
-
   result->surplus[FOOD] = pcity->food_surplus;
   result->surplus[SHIELD] = pcity->shield_surplus;
   result->surplus[TRADE] = pcity->trade_prod;
 
-  result->production[GOLD] = pcity->tax_total;
-  result->production[LUXURY] = pcity->luxury_total;
-  result->production[SCIENCE] = pcity->science_total;
-
   result->surplus[GOLD] = city_gold_surplus(pcity);
-  result->surplus[LUXURY] = result->production[LUXURY];
-  result->surplus[SCIENCE] = result->production[SCIENCE];
+  result->surplus[LUXURY] = pcity->luxury_total;
+  result->surplus[SCIENCE]= pcity->science_total;
 
   result->disorder = city_unhappy(pcity);
   result->happy = city_happy(pcity);
@@ -528,16 +525,14 @@ static void update_cache2(struct city *p
    * unhappy_city_check.
    */
   if (!result->disorder) {
-    p = get_secondary_stat(result->production[TRADE],
+    p = get_secondary_stat(result->surplus[TRADE],
                           result->specialists[SP_SCIENTIST],
                           SP_SCIENTIST);
     if (!p->is_valid) {
-      p->production = result->production[SCIENCE];
       p->surplus = result->surplus[SCIENCE];
       p->is_valid = TRUE;
     } else {
-      assert(p->production == result->production[SCIENCE] &&
-            p->surplus == result->surplus[SCIENCE]);
+      assert(p->surplus == result->surplus[SCIENCE]);
     }
   }
 
@@ -546,34 +541,30 @@ static void update_cache2(struct city *p
    * unhappy_city_check.
    */
   if (!result->disorder) {
-    p = get_secondary_stat(result->production[TRADE],
+    p = get_secondary_stat(result->surplus[TRADE],
                           result->specialists[SP_TAXMAN],
                           SP_TAXMAN);
     if (!p->is_valid && !result->disorder) {
-      p->production = result->production[GOLD];
       p->surplus = result->surplus[GOLD];
       p->is_valid = TRUE;
     } else {
-      assert(p->production == result->production[GOLD] &&
-            p->surplus == result->surplus[GOLD]);
+      assert(p->surplus == result->surplus[GOLD]);
     }
   }
 
-  p = get_secondary_stat(result->production[TRADE],
+  p = get_secondary_stat(result->surplus[TRADE],
                         result->specialists[SP_ELVIS],
                         SP_ELVIS);
   if (!p->is_valid) {
-    p->production = result->production[LUXURY];
     p->surplus = result->surplus[LUXURY];
     p->is_valid = TRUE;
   } else {
     if (!result->disorder) {
-      assert(p->production == result->production[LUXURY] &&
-            p->surplus == result->surplus[LUXURY]);
+      assert(p->surplus == result->surplus[LUXURY]);
     }
   }
 
-  q = get_city_status(result->production[LUXURY],
+  q = get_city_status(result->surplus[LUXURY],
                      count_worker(pcity, result));
   if (!q->is_valid) {
     q->disorder = result->disorder;
@@ -619,8 +610,7 @@ static void real_fill_out_result(struct 
 
   /* Do checks */
   if (pcity->size != worker + get_num_specialists(result)) {
-    print_city(pcity);
-    print_result(pcity, result);
+    cm_print_result(pcity, result, TRUE);
     assert(0);
   }
 
@@ -647,7 +637,7 @@ static void real_fill_out_result(struct 
   /* Do a local recalculation of the city */
   generic_city_refresh(pcity, FALSE, NULL);
 
-  copy_stats(pcity, result);
+  cm_copy_result_from_city(pcity, result);
 
   /* Restore */
   memcpy(pcity, &backup, sizeof(struct city));
@@ -656,10 +646,10 @@ static void real_fill_out_result(struct 
          "sci=%d lux=%d tax=%d dis=%s happy=%s",
          count_worker(pcity, result), result->specialists[SP_ELVIS],
          result->specialists[SP_SCIENTIST], result->specialists[SP_TAXMAN],
-         result->production[TRADE],
-         result->production[SCIENCE],
-         result->production[LUXURY],
-         result->production[GOLD],
+         result->surplus[TRADE],
+         result->surplus[SCIENCE],
+         result->surplus[LUXURY],
+         result->surplus[GOLD],
          result->disorder ? "yes" : "no", result->happy ? "yes" : "no");
   update_cache2(pcity, result);
 }
@@ -681,17 +671,7 @@ static void calc_fitness(struct city *pc
   *minor_fitness = 0;
 
   for (i = 0; i < NUM_STATS; i++) {
-    int base;
-    if (parameter->factor_target == FT_SURPLUS) {
-      base = result->surplus[i];
-    } else if (parameter->factor_target == FT_EXTRA) {
-      base = parameter->minimal_surplus[i] - result->surplus[i];
-    } else {
-      base = 0;
-      assert(0);
-    }
-
-    *major_fitness += base * parameter->factor[i];
+    *major_fitness += result->surplus[i] * parameter->factor[i];
     *minor_fitness += result->surplus[i];
   }
 
@@ -843,42 +823,37 @@ static void fill_out_result(struct city 
      * all_entertainer result
      */
     for (i = 0; i < NUM_PRIMARY_STATS; i++) {
-      result->production[i] =
-         base_combination->all_entertainer.production[i];
       result->surplus[i] = base_combination->all_entertainer.surplus[i];
     }
 
-    p = get_secondary_stat(result->production[TRADE],
+    p = get_secondary_stat(result->surplus[TRADE],
                           result->specialists[SP_SCIENTIST],
                           SP_SCIENTIST);
     if (!p->is_valid) {
       got_all = FALSE;
     } else {
-      result->production[SCIENCE] = p->production;
       result->surplus[SCIENCE] = p->surplus;
     }
 
-    p = get_secondary_stat(result->production[TRADE],
+    p = get_secondary_stat(result->surplus[TRADE],
                           result->specialists[SP_TAXMAN],
                           SP_TAXMAN);
     if (!p->is_valid) {
       got_all = FALSE;
     } else {
-      result->production[GOLD] = p->production;
       result->surplus[GOLD] = p->surplus;
     }
 
-    p = get_secondary_stat(result->production[TRADE],
+    p = get_secondary_stat(result->surplus[TRADE],
                           result->specialists[SP_ELVIS],
                           SP_ELVIS);
     if (!p->is_valid) {
       got_all = FALSE;
     } else {
-      result->production[LUXURY] = p->production;
       result->surplus[LUXURY] = p->surplus;
     }
 
-    q = get_city_status(result->production[LUXURY],
+    q = get_city_status(result->surplus[LUXURY],
                        base_combination->worker);
     if (!q->is_valid) {
       got_all = FALSE;
@@ -1352,7 +1327,7 @@ static void optimize_final(struct city *
     for (i = 0; i < MAX_COMBINATIONS; i++) {
       struct combination *current =
          &cache3.results[fields_used].combinations[i];
-      int stat, major_fitness, minor_fitness;
+      int major_fitness, minor_fitness;
       struct cm_result result;
 
       if (!current->is_valid) {
@@ -1365,20 +1340,6 @@ static void optimize_final(struct city *
       fill_out_result(pcity, &result, current, 0, 0);
 
       /*
-       * Check. The actual production can be bigger because of city
-       * improvements such a Factory.
-       */
-      for (stat = 0; stat < NUM_PRIMARY_STATS; stat++) {
-       if (result.production[stat] < current->production2[stat]) {
-         freelog(LOG_NORMAL, "expected:");
-         print_combination(pcity, current);
-         freelog(LOG_NORMAL, "got:");
-         print_result(pcity, &result);
-         assert(0);
-       }
-      }
-
-      /*
        * the secondary stats aren't calculated yet but we want to use
        * is_valid_result()
        */
@@ -1562,9 +1523,6 @@ bool cm_are_parameter_equal(const struct
   if (p1->allow_specialists != p2->allow_specialists) {
     return FALSE;
   }
-  if (p1->factor_target != p2->factor_target) {
-    return FALSE;
-  }
   if (p1->happy_factor != p2->happy_factor) {
     return FALSE;
   }
Index: common/aicore/cm.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.h,v
retrieving revision 1.6
diff -b -u -p -r1.6 cm.h
--- common/aicore/cm.h  16 Jun 2004 03:01:02 -0000      1.6
+++ common/aicore/cm.h  13 Jul 2004 22:42:11 -0000
@@ -29,11 +29,6 @@
 #include "city.h"              /* CITY_MAP_SIZE */
 #include "shared.h"            /* bool type */
 
-enum factor_target {
-  FT_SURPLUS,                  /* will use the surplus as base */
-  FT_EXTRA                     /* will use (minimal_surplus-surplus) as base */
-};
-
 enum cm_stat { FOOD, SHIELD, TRADE, GOLD, LUXURY, SCIENCE, NUM_STATS };
 
 /* A description of the goal. */
@@ -43,8 +38,6 @@ struct cm_parameter {
   bool allow_disorder;
   bool allow_specialists;
 
-  enum factor_target factor_target;
-
   int factor[NUM_STATS];
   int happy_factor;
 };
@@ -53,7 +46,6 @@ struct cm_parameter {
 struct cm_result {
   bool found_a_valid, disorder, happy;
 
-  int production[NUM_STATS];
   int surplus[NUM_STATS];
 
   bool worker_positions_used[CITY_MAP_SIZE][CITY_MAP_SIZE];
@@ -89,4 +81,8 @@ bool cm_are_parameter_equal(const struct
                            const struct cm_parameter *const p2);
 void cm_copy_parameter(struct cm_parameter *dest,
                       const struct cm_parameter *const src);
+
+void cm_print_result(const struct city*, const struct cm_result*, 
+        bool do_print_city);
+void cm_copy_result_from_city(const struct city*, struct cm_result*);
 #endif
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.253
diff -b -u -p -r1.253 cityturn.c
--- server/cityturn.c   13 Jul 2004 18:16:54 -0000      1.253
+++ server/cityturn.c   13 Jul 2004 22:42:12 -0000
@@ -198,7 +198,6 @@ void auto_arrange_workers(struct city *p
   cmp.require_happy = FALSE;
   cmp.allow_disorder = FALSE;
   cmp.allow_specialists = TRUE;
-  cmp.factor_target = FT_SURPLUS;
 
   /* We used to look at pplayer->ai.xxx_priority to determine the values
    * to be used here.  However that doesn't work at all because those values

[Prev in Thread] Current Thread [Next in Thread]