[Freeciv-Dev] Re: (PR#12315) Slowness (fix)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12315 >
Here is a different way to speed up government selection. We add a
government hint that some governments are superceded by others, and don't
evaluate these. So if we can use Monarchy, we skip Despotism. If we have
Communism, we skip Monarchy. If we have (more controversially, perhaps)
Democracy, we skip Republic.
This should make a very big difference in the speed of govt selection.
- Per
Index: common/government.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.h,v
retrieving revision 1.38
diff -u -r1.38 government.h
--- common/government.h 22 Jan 2005 21:12:10 -0000 1.38
+++ common/government.h 18 Mar 2005 13:05:47 -0000
@@ -69,6 +69,8 @@
char graphic_alt[MAX_LEN_NAME];
int required_tech; /* tech required to change to this gov */
+ int ai_better; /* govt AI prefers to this one (hint) */
+
struct ruler_title *ruler_titles;
int num_ruler_titles;
Index: data/civ1/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/governments.ruleset,v
retrieving revision 1.22
diff -u -r1.22 governments.ruleset
--- data/civ1/governments.ruleset 18 Mar 2005 12:46:31 -0000 1.22
+++ data/civ1/governments.ruleset 18 Mar 2005 13:05:47 -0000
@@ -180,6 +180,7 @@
graphic = "gov.despotism"
graphic_alt = "-"
flags = "-"
+ai_better = "Monarchy"
martial_law_max = 100 ; unlimited
martial_law_per = 1
@@ -253,6 +254,7 @@
graphic = "gov.monarchy"
graphic_alt = "-"
flags = "-"
+ai_better = "Communism"
martial_law_max = 100 ; unlimited
martial_law_per = 1
@@ -403,6 +405,7 @@
graphic = "gov.republic"
graphic_alt = "-"
flags = "Has_Senate", "Rapture_City_Growth"
+ai_better = "Democracy"
martial_law_max = 0
martial_law_per = 0
Index: data/civ2/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/governments.ruleset,v
retrieving revision 1.30
diff -u -r1.30 governments.ruleset
--- data/civ2/governments.ruleset 18 Mar 2005 12:46:31 -0000 1.30
+++ data/civ2/governments.ruleset 18 Mar 2005 13:05:47 -0000
@@ -177,6 +177,7 @@
graphic = "gov.despotism"
graphic_alt = "-"
flags = "-"
+ai_better = "Monarchy"
martial_law_max = 100 ; unlimited
martial_law_per = 1
@@ -252,6 +253,7 @@
graphic = "gov.monarchy"
graphic_alt = "-"
flags = "-"
+ai_better = "Communism"
martial_law_max = 3
martial_law_per = 1
@@ -492,6 +494,7 @@
graphic = "gov.republic"
graphic_alt = "-"
flags = "Has_Senate", "Rapture_City_Growth"
+ai_better = "Democracy"
martial_law_max = 0
martial_law_per = 0
Index: data/default/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/governments.ruleset,v
retrieving revision 1.27
diff -u -r1.27 governments.ruleset
--- data/default/governments.ruleset 18 Mar 2005 12:46:31 -0000 1.27
+++ data/default/governments.ruleset 18 Mar 2005 13:05:47 -0000
@@ -17,7 +17,6 @@
[governments]
default="Despotism"
when_anarchy="Anarchy"
-ai_goal="Republic"
; Below: The individual government types, one per section.
;
@@ -40,6 +39,8 @@
; should be a standard tag if preferred is not;
; otherwise may be "-"
; flags = special effects; see government.c for strings
+; ai_better = AI will not consider this government for use if the
+; government listed here is available
; martial_law_max = maximum number of units which can enforce martial law
; in the city
@@ -165,6 +166,7 @@
graphic = "gov.despotism"
graphic_alt = "-"
flags = "-"
+ai_better = "Monarchy"
martial_law_max = 100 ; unlimited
martial_law_per = 1
@@ -223,6 +225,7 @@
graphic = "gov.monarchy"
graphic_alt = "-"
flags = "-"
+ai_better = "Communism"
martial_law_max = 3
martial_law_per = 1
@@ -345,6 +348,7 @@
graphic = "gov.republic"
graphic_alt = "-"
flags = "Has_Senate", "Rapture_City_Growth"
+ai_better = "Democracy"
martial_law_max = 0
martial_law_per = 0
Index: data/history/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/governments.ruleset,v
retrieving revision 1.8
diff -u -r1.8 governments.ruleset
--- data/history/governments.ruleset 18 Mar 2005 12:46:32 -0000 1.8
+++ data/history/governments.ruleset 18 Mar 2005 13:05:47 -0000
@@ -178,6 +178,7 @@
graphic = "gov.despotism"
graphic_alt = "-"
flags = "-"
+ai_better = "Monarchy"
martial_law_max = 100 ; unlimited
martial_law_per = 1
@@ -253,6 +254,7 @@
graphic = "gov.monarchy"
graphic_alt = "-"
flags = "-"
+ai_better = "Communism"
martial_law_max = 3
martial_law_per = 1
@@ -408,6 +410,7 @@
graphic = "gov.republic"
graphic_alt = "-"
flags = "Has_Senate", "Rapture_City_Growth"
+ai_better = "Democracy"
martial_law_max = 0
martial_law_per = 0
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.232
diff -u -r1.232 ruleset.c
--- server/ruleset.c 18 Mar 2005 12:46:32 -0000 1.232
+++ server/ruleset.c 18 Mar 2005 13:05:47 -0000
@@ -1580,7 +1580,15 @@
int i = g->index;
const char *waste_name[] = {NULL, "waste", "corruption",
NULL, NULL, NULL};
-
+
+ if (section_file_lookup(file, "%s.ai_better", sec[i])) {
+ char entry[100];
+
+ my_snprintf(entry, sizeof(entry), "%s.ai_better", sec[i]);
+ g->ai_better = lookup_government(file, entry, filename);
+ } else {
+ g->ai_better = G_MAGIC;
+ }
g->required_tech
= lookup_tech(file, sec[i], "tech_req", FALSE, filename, g->name);
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.105
diff -u -r1.105 aihand.c
--- ai/aihand.c 18 Mar 2005 12:41:38 -0000 1.105
+++ ai/aihand.c 18 Mar 2005 13:06:18 -0000
@@ -266,6 +266,10 @@
if (gov->index == game.government_when_anarchy) {
continue; /* pointless */
}
+ if (gov->ai_better != G_MAGIC
+ && can_change_to_government(pplayer, gov->ai_better)) {
+ continue; /* we have better governments available */
+ }
pplayer->government = gov->index;
/* Ideally we should change tax rates here, but since
* this is a rather big CPU operation, we'd rather not. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
|
|