webperimental: killstack decides stack protects.
[freeciv.git] / doc / README.governor
blob661e6050401a7793ea2f88ee83778ca289d2e8cf
2   Citizen Governor (aka Citizen Management Agent, or CMA)
3 =========================================================
5 The Citizen Governor is designed to help you manage your cities, i.e.
6 deploy the workers on the available tiles around (or make them
7 scientists, taxmen, or even entertainers), to get the most out of the
8 city. You can switch the Governor on or off at any time for any city,
9 but there are some handicaps (explained below), if you have governor
10 controlled and non-governor-controlled cities nearby.
12 The heart of Governor system is an optimizing algorithm, that tries
13 to deploy the workers of a city in such a way, that a user-defined
14 goal is achieved as much as possible. You know probably, there is
15 already a kind of optimizing, when you open a city, and click on
16 the center tile (the city symbol) of the mini map. This optimization
17 tries to maximize mostly the science output; but it doesn't care about
18 disorder.
20 The new City Management Agent goes far beyond this old form of
21 optimizing. First, it performs this task every time anything changes
22 with the city. If the city grows or shrinks, troops go in or out,
23 tiles get irrigation or mining, or are occupied by an enemy, the Governor
24 becomes active. Second, it supports all kinds of optimizing, like
25 production (shields), gold, science, or luxury. Third, it gives the
26 player a fine-grained control over this, with the possibility of
27 setting constraints for any kind of city output. The latter includes
28 the constraint of celebration, which makes it very easy to let your
29 cities grow, even in harder times. The forth, and probably most
30 valuable thing in war times, is that is keeps your cities content,
31 preventing them from revolt.
34   Usage
35 =========
37 You can set up the Governor for a city by opening the city window and
38 clicking on the Governor tab. On the left side, you can choose a preset for
39 a specified goal, on the right side you can specify more complex goals
40 by moving the sliders. You can choose a preset at first, and then
41 modify it. Once you have created a new setting, you can add a preset
42 name for it. This is not required, but very useful, since you can
43 watch and even change the city's setting from within the city report,
44 if it is given a name. Don't forget to save settings (in the Game
45 menu), when you've created new presets.
47 The sliders are of two kinds: the rightmost sliders are factors, which
48 gauges how much one product is worth compared to the others (e.g how
49 much shields are worth with respect to everything else). The leftmost
50 sliders are constraints: you can command the city not to lose food,
51 e.g. by setting the surplus constraint to zero; and you can allow the
52 city to lose gold by setting the gold surplus to -3 e.g., and urge
53 them to make at least 5 shields per round by setting the production
54 surplus to 5. The most powerful constraint, though, is the Celebrate
55 constraint, which makes the city celebrate at once (which usually takes
56 effect the round after you change it).
58 It is obvious that the Governor can't fulfill all these constraints in
59 every case. Whenever the constraints can't be fulfilled, the Governor
60 quits its service for that city, giving a message: "The agent can't
61 fulfill the requirements for Berlin. Passing back control." You then
62 have the choice of either managing the city on your own (which has some
63 drawbacks, see below), or open that city and change the surplus
64 requirements so that they can be fulfilled.
66 When you have made a setup for a city, you need to click on 
67 "Control city" to switch on the Governor. If this button's text is greyed,
68 either the Governor is already active, or the task is impossible. In the
69 latter case you see dashes instead of numbers in the results block.
70 If you ever want to switch off the Governor deliberately, click "Release
71 city".
74   Advanced Usage
75 ==================
77 Usually the goal(s) of your cities depend on the phase your game is in,
78 whether you want to spread widely, grow quickly, research advanced techs
79 or wage war. You may want to set up a high factor for science to research,
80 or a high shields factor to produce units. The highest factor available
81 is 25, that means: if the shields factor is set to 25, and other to 1,
82 the Governor prefers a single shield over 25 gold (or trade also). This is
83 pretty much because money can buy units too. That also means that
84 the Governor is indifferent about producing gold, science, luxury, and food;
85 but when you wage war, you usually prefer gold or luxury. So it's probably
86 a good idea to set a second (or even third) preference for the city's output,
87 e.g. gold factor 5. That still prefers 1 shield over 5 gold (and 1 gold over 5
88 food or anything else).
90 Constraints aren't useful in all cases. If you want a high income,
91 it's probably better to set the gold factor to 25, than to set a
92 minimal surplus of 5 or so. Because a big city can make more gold than
93 a small one, you'd end up setting a different surplus for each city.
95 However, if the shields surplus of a city is below zero, it cannot
96 support all of its units any more. You will lose some of the units the
97 city supports. If the food surplus is negative, the city will starve
98 and eventually (when the granary is empty) shrink. This may be
99 intended, but if the city supports any settlers, you will lose them
100 before the city shrinks. Constraints can also have a warning function.
102 Which constraints can be fulfilled depends widely on the global
103 science, tax, and luxury rates. E.g. a gold surplus >= 0 is easier to
104 fulfill with a higher tax rate than a lower one. You should always
105 consider to change these rates, when you going to change the Governor
106 settings for the most of your cities.
108 Hint: To avoid accidentally releasing your cities, when you change the
109 rates, it is best to do so from within the tax dialog rather than from
110 the rates display in the main window.
113   Drawbacks
114 =============
116 The Governor is a very powerful tool, which not only releases you from the
117 micromanagement of your cities, but gives you more performance than
118 you have ever seen (well, for most players).
120 There are some drawbacks, though. Once you've switched on the Governor, it
121 grabs any good tile it can get. So you encounter very hard times
122 trying to manage a city nearby a Governor-controlled one. This is true for
123 the city window and the main map worker's interface as well. If you
124 want to have Governor-controlled and "handmade" cities, they probably
125 should be on different islands.
127 There are several situations where the Governor can't fulfill the
128 requirements just temporarily, e.g. when you move a ship from one city
129 to another, or when an enemy walks through your country. The Governor
130 passes back control in these cases, and you have to reenable it
131 manually. A general approach to prevent this might be, to set the
132 minimal surpluses as low as possible (-20). Of course you must be
133 careful with the food and shield surpluses.
135 While the Governor does a really good job for a single city, no tile will
136 ever be released for the good of another city. Also, the Governor controlled
137 cities are computed in a more random order; the results may depend on it and
138 change, when a recalculation is done (when tax changes e.g.). So, no
139 guarantee is given that the overall results are always optimal.
142   Settings file
143 =================
145 The client allows the user to load and save preset parameters for the
146 agent. Choosing "Save Settings" from the "Game" menu will not only
147 save your general options and message options, but it will save any
148 changes you made to you Governor presets as well.
150 The format for the options file (usually ~/.freeciv/.freeciv-client-rc-X.Y , where X.Y
151 is the version of freeciv in use) is as follows (in case you which to change
152 these presets manually, i.e. with a text editor).
154 Under the heading [cma], is a "number_of_presets". This should be set
155 to the number of presets that are present in the options file. If you
156 manually add or remove a preset, you need to change this number as
157 appropriate.
159 After this, is an array that houses the presets. Here is the header:
161 preset={ "name","minsurp0","factor0","minsurp1","factor1","minsurp2",
162 "factor2","minsurp3","factor3","minsurp4","factor4","minsurp5",
163 "factor5","reqhappy","factortarget","happyfactor"
165 so the order of the preset should be as follows: 
167 name of preset, minimal surplus 0, factor 0, ... , 
168 require city to be happy, what the target should be [0,1], 
169 the happiness factor
171 Currently there are 6 surpluses and factors. They are:
172 0 = food, 1 = production, 2 = trade, 3 = gold, 4 = luxury,
173 5 = science
175 Also currently, "factortarget" is not changeable within the client,
176 see "client/agents/cma_core.h" for more information.
178 The array should be terminated with a '}'.
180 Here are 21 presets you can use if you can't come up with some on 
181 your own:
183 "Max food",0,10,0,1,0,1,0,1,0,1,0,1,0,0,1
184 "Max production",0,1,0,10,0,1,0,1,0,1,0,1,0,0,1
185 "Max trade",0,1,0,1,0,10,0,1,0,1,0,1,0,0,1
186 "Max tax",0,1,0,1,0,1,0,10,0,1,0,1,0,0,1
187 "Max luxury",0,1,0,1,0,1,0,1,0,10,0,1,0,0,1
188 "Max science",0,1,0,1,0,1,0,1,0,1,0,10,0,0,1
189 "+2 food",2,1,0,1,0,1,0,1,0,1,0,1,0,0,1
190 "+2 production",0,1,2,1,0,1,0,1,0,1,0,1,0,0,1
191 "+2 trade",0,1,0,1,2,1,0,1,0,1,0,1,0,0,1
192 "+2 gold",0,1,0,1,0,1,2,1,0,1,0,1,0,0,1
193 "+2 luxury",0,1,0,1,0,1,0,1,2,1,0,1,0,0,1
194 "+2 science",0,1,0,1,0,1,0,1,0,1,2,1,0,0,1
195 "Max food no gold limit",0,10,0,1,0,1,-20,1,0,1,0,1,0,0,1
196 "Max production no gold limit",0,1,0,10,0,1,-20,1,0,1,0,1,0,0,1
197 "Max trade no gold limit",0,1,0,1,0,10,-20,1,0,1,0,1,0,0,1
198 "Max gold no gold limit",0,1,0,1,0,1,-20,10,0,1,0,1,0,0,1
199 "Max luxury no gold limit",0,1,0,1,0,1,-20,1,0,10,0,1,0,0,1
200 "Max science no gold limit",0,1,0,1,0,1,-20,1,0,1,0,10,0,0,1
201 "Max food+prod. no gold limit",0,10,0,10,0,1,-20,1,0,1,0,1,0,0,1
202 "Max food+prod.+trade",0,10,0,10,0,10,0,1,0,1,0,1,0,0,1
203 "Max all",0,1,0,1,0,1,0,1,0,1,0,1,0,0,1
205 here are 6 more that have been added as an afterthought:
207 "+1 food, max prod. no gold limit",1,1,0,10,0,1,-20,1,0,1,0,1,0,0,1
208 "+2 food, max prod. no gold limit",2,1,0,10,0,1,-20,1,0,1,0,1,0,0,1
209 "+3 food, max prod. no gold limit",3,1,0,10,0,1,-20,1,0,1,0,1,0,0,1
210 "+4 food, max prod. no gold limit",4,1,0,10,0,1,-20,1,0,1,0,1,0,0,1
211 "+5 food, max prod. no gold limit",5,1,0,10,0,1,-20,1,0,1,0,1,0,0,1
212 "+6 food, max prod. no gold limit",6,1,0,10,0,1,-20,1,0,1,0,1,0,0,1
214 and even more, some with multiple goals:
216 "research at any cost",0,1,0,5,-20,1,-20,1,-20,1,-20,25,0,0,1
217 "celebration and growing",1,1,0,25,-20,1,-20,12,-20,1,-20,1,1,0,1
218 "grow at any cost",1,25,0,5,-20,1,-20,1,-20,1,-20,5,0,0,1
219 "research and some shields",0,1,0,8,0,1,-3,1,0,1,0,25,0,0,1
220 "shields and a bit money",0,1,0,25,0,1,-3,3,0,1,0,1,0,0,1
221 "many shields and some money",0,1,0,25,0,1,0,9,0,1,0,1,0,0,1
222 "shields and some research",0,1,0,25,0,1,-2,1,0,1,0,8,0,0,1
223 "celebrate and grow at once",1,1,0,25,-20,1,-20,1,-20,1,-20,8,1,0,1
225 Last updated: 10 Apr 2015