Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2005:
[Freeciv-Dev] (PR#11905) the new auto_arrange_workers is really slow
Home

[Freeciv-Dev] (PR#11905) the new auto_arrange_workers is really slow

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11905) the new auto_arrange_workers is really slow
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Jan 2005 23:46:03 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11905 >

Here's a version of the patch for 2.0.

Actually I was wrong - the "bad" settings are included for AI players
only, not for human players.  So this change should have a pretty big
effect.

In my late-game measurements I find this speeds the server overall by
5-20% (of course autogames are changed so this is hard to measure).

-jason

? win32.diff
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.267.2.10
diff -u -r1.267.2.10 cityturn.c
--- server/cityturn.c   21 Dec 2004 22:57:26 -0000      1.267.2.10
+++ server/cityturn.c   18 Jan 2005 07:43:52 -0000
@@ -264,21 +264,19 @@
        }
       }
     } else {
-      cmp.minimal_surplus[FOOD] = 0;
+      /* Drop surpluses and try again.  This allows us to starve but not to
+       * run short on shields.  Disorder is still not allowed (we'd rather
+       * shrink than go to disorder). */
+      cmp.minimal_surplus[FOOD] = MIN(pcity->food_surplus, 0);
       cmp.minimal_surplus[SHIELD] = 0;
       cmp.minimal_surplus[GOLD] = -FC_INFINITY;
       cm_query_result(pcity, &cmp, &cmr);
 
       if (!cmr.found_a_valid) {
-       cmp.minimal_surplus[FOOD] = -(pcity->food_stock);
-       cmp.minimal_surplus[TRADE] = -FC_INFINITY;
-       cm_query_result(pcity, &cmp, &cmr);
-      }
-
-      if (!cmr.found_a_valid) {
        /* Emergency management.  Get _some_ result.  This doesn't use
         * cm_init_emergency_parameter so we can keep the factors from
-        * above. */
+        * above.  At this point all minimums are dropped and disorder is
+        * allowed. */
        cmp.minimal_surplus[FOOD] = MIN(cmp.minimal_surplus[FOOD],
                                        MIN(pcity->food_surplus, 0));
        cmp.minimal_surplus[SHIELD] = MIN(cmp.minimal_surplus[SHIELD],

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