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

 Problem with high researchcost (and custom ruleset):
 AI builts a lot of buildings and then it has problem with maintenance
costs. It starts building coinage. However, tax rate setting logic
does not consider income from coinage at all. Instead it wants
positive balance even without coinage. So it sets tax rate to 100%.
End result is that nation has highly positive balance, but it keeps
science rate at 0%. I just observed one game up to point where AI had
collected 20000 gold and still had 100% tax rate.
 In short: problem is that tax rate setting logic does not consider
income from coinage.

 However, that problem is very hard to fix without causing other
problems. So attached patch fights the symptoms. AI accepts slightly
negative balance if it has gold reserves for that. More precisely:
negative balance is acceptable if AI could with its current gold
reserves live up to 50 turns with such a balance.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aihand.c freeciv/ai/aihand.c
--- freeciv/ai/aihand.c	2006-07-17 23:56:47.000000000 +0300
+++ freeciv/ai/aihand.c	2007-01-28 18:03:17.000000000 +0200
@@ -66,6 +66,10 @@
 
 #define LOGLEVEL_TAX LOG_DEBUG
 
+/* When setting rates, we accept negative balance if we have a lot of
+ * gold reserves. This is how long time gold reserves should last */
+#define AI_GOLD_RESERVE_MIN_TURNS 50
+
 /**************************************************************************
  handle spaceship related stuff
 **************************************************************************/
@@ -127,7 +131,8 @@
   pplayer->economic.luxury = (100 - pplayer->economic.science
                              - pplayer->economic.tax); /* Spillover */
 
-  /* Now find the minimum tax with positive balance */
+  /* Now find the minimum tax with positive balance
+   * Negative balance is acceptable if we have a lot of gold. */
   while(pplayer->economic.tax < maxrate
         && (pplayer->economic.science > 0
             || pplayer->economic.luxury > 0)) {
@@ -142,7 +147,8 @@
     rates[TAX] = 100 - rates[SCIENCE] - rates[LUXURY];
     distribute(trade, 3, rates, result);
 
-    if (expenses - result[TAX] > 0) {
+    if (expenses - result[TAX] > pplayer->economic.gold / AI_GOLD_RESERVE_MIN_TURNS) {
+      /* Clearly negative balance. Unacceptable */
       pplayer->economic.tax += 10;
       if (pplayer->economic.luxury > 0) {
         pplayer->economic.luxury -= 10;
@@ -150,7 +156,8 @@
         pplayer->economic.science -= 10;
       }
     } else {
-      /* Ok, got positive balance */
+      /* Ok, got positive balance
+       * Or just slightly negative, but we can afford that for a while */
       if (pplayer->economic.gold < ai_gold_reserve(pplayer)) {
         /* Need to refill coffers, increase tax a bit */
         pplayer->economic.tax += 10;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to