better massage worker/engineer want

Per Inge Mathisen <per-0/[email protected]>
Newsgroups gmane.games.freeciv.ai
Message-ID <[email protected]>
In large games with a large number of cities, the existing massage of
engineer want does not work so well. I therefore made it more aggressive
in keeping the number of workers down. I also improved the logging a bit.

I commit this right away.

  - Per

Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.200
diff -u -r1.200 settlers.c
--- server/settlers.c   13 Sep 2004 15:54:54 -0000      1.200
+++ server/settlers.c   15 Sep 2004 09:55:43 -0000
@@ -1528,14 +1528,18 @@
   want = evaluate_improvements(virtualunit, &best_act, &gx, &gy);
   free(virtualunit);

-  /* modify our desire based on available statistics to prevent
+  /* Massage our desire based on available statistics to prevent
    * overflooding with worker type units if they come cheap in
    * the ruleset */
   want /= MAX(1, ai->stats.workers[ptile->continent]
-                 / MAX(1, ai->stats.cities[ptile->continent]));
+                 / ai->stats.cities[ptile->continent]);
+  want -= MIN(ai->stats.workers[ptile->continent], want);

-  CITY_LOG(LOG_DEBUG, pcity, "wants %s with want %d to do %s at (%d,%d)",
-          unit_name(unit_type), want, get_activity_text(best_act), gx, gy);
+  CITY_LOG(LOG_DEBUG, pcity, "wants %s with want %d to do %s at (%d,%d), "
+           "we have %d workers and %d cities on the continent",
+          unit_name(unit_type), want, get_activity_text(best_act), gx, gy,
+           ai->stats.workers[ptile->continent],
+           ai->stats.cities[ptile->continent]);
   assert(want >= 0);
   pcity->ai.settler_want = want;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.