]> git.pond.sub.org Git - empserver/blob - info/Concepts/Innards.t
Import of Empire 4.2.12
[empserver] / info / Concepts / Innards.t
1 .TH Concept Innards
2 .NA Innards "Some details about the inner workings of the server"
3 .LV Expert
4 .s1
5 Much of this file is now out-of-date.  Correct information may be found
6 in the files Update-sequence and build.
7 .s1
8 This topic contains fairly nitty-gritty descriptions of
9 some of the underlying mechanisms in the Empire system.
10 It is not meant for the weak-of-heart or casual reader.
11 (And it's usually out of date.)
12 .s1
13 Sector Updates
14 .s1
15 Several characteristics of the Empire game are dependent on
16 sector updates --
17 mobility, efficiency, mining of ore, generation
18 of production units, etc.
19 .s1
20 An understanding of the calculations
21 involved is often helpful in planning the timing of various
22 actions
23 and although it is unlikely that this description
24 is strictly up to date,
25 it should provide a feel for the overall philosophy.
26 .s1
27 All commodities in a sector are kept as \*Qshort integers\*U.
28 The program cannot have \*Qnegative commodity values\*U, so the
29 theoretical capacity of a sector is 32767, while in practice
30 it is actually 9999 (for formatting reasons).
31 While it is possible to move more commodities than 9999 into
32 sectors, production of commodities will not go
33 above the level of 999.
34 So, an update that produces 450 units of iron in a sector that already
35 has 800 units can at most add 199 units.
36 .s1
37 Here is an approximate description of the algorithm that is
38 called whenever an update occurs:
39 .s1
40 Variables used are:
41 .in \w'workforce\0\0'u
42 .L etus
43 the # of Empire time units in this update
44 .L civ
45 civilians in the sector
46 .L mil
47 military in the sector
48 .L uw
49 uncompensated workers in the sector
50 .L desig
51 designation of the sector
52 .L effic
53 efficiency of the sector
54 .L miner
55 iron mineral content of the sector
56 .L gold
57 gold mineral content of the sector
58 .L t_level
59 technology level of the country
60 .L r_level
61 research level of the country
62 .L p_stage
63 plague stage in the sector
64 .L p_time
65 plague stage duration
66 .L workforce
67 an intermediate variable that represents work potential
68 .L work
69 the amount of work done in the sector
70 .in
71 .s1
72 Parameters used are (see the \*Qversion\*U command for actual values):
73 .in \w'uwbrate\0\0'u
74 .L s_p_etu
75 seconds per Empire time unit
76 .L fgrate
77 the food growth rate
78 .L fcrate
79 the food cultivation rate
80 .L eatrate
81 how much food people eat
82 .L obrate
83 birth rate
84 .L uwbrate
85 uncompensated worker birth rate
86 .L babyeat
87 how much babies eat growing up
88 .L bankint
89 bank interest rate in $/bar
90 .in
91 .nf
92 .s1
93 workforce = (civ*100/sector work + uw + mil / 5.) / 100.
94 If workforce = 0 go away and don't update anything
95
96 /* increase sector efficiency */
97 If the weather is good enough for construction and we're not broke then
98   effic becomes effic + work (if possible) and costs $1 for each
99   percentage point gained.
100 Otherwise charge the $1 for each percentage point that would have been
101   gained, (pay for workers to play cards).
102
103 /* grow some food */
104 Set dd = etu * sector_fertility * fgrate
105     (this is the amount of food that can be grown in etu time units)
106 Set dtemp = work * 100. * fcrate
107     (this is the amount of food that the people there can harvest)
108 If (dtemp < dd)     (if there aren't enough people to harvest it all)
109     set dd = dtemp
110 Set foodtmp to the amount of food in the sector plus dd
111
112 /* feed the masses */
113 If desig is sanctuary then
114     set dd equal to 0.
115 Else
116     set dd equal to etu * (civ + mil) * eatrate
117         (this is the amount of food the people need to eat)
118 If (dd > foodtmp) then some people will starve
119     figure out what percentage of the population can be fed,
120     and kill the rest (up to a maximum of 1/2 the populace)
121     set food = 0
122 Otherwise
123     set food = foodtmp - dd (with a maximum of 999)
124
125 /* population growth */
126 set q = etu * civ * obrate
127         the number of births possible in other sectors
128 If q is bigger than food / (2 * babyeat) set q to food / (2 * babyeat)
129         food available to mature this many babies into civilians
130 If q is bigger than 999 - civ set q to 999 - civ
131         enough room for that many
132 Set food = food - q * babyeat
133 Set civ = civ + q
134
135 /* mobility */
136 Add etu to mobil (to a max of 127)
137
138 /* pay taxes */
139 Collect the taxes, pay the military
140     civ_tax = (int) (.5 + (civs * eff * etu * civtaxrate / 100.));
141     if (conquered) civ_tax /= 4.;
142     uw_tax  = (int) (.5 + (uws  * eff * etu * uwtaxrate  / 100.));
143     mil_pay = (int) (mil * etu * milpayrate);
144
145     nat_money -= mil_pay
146     nat_money += civ_tax + uw_tax
147
148 /* plague */
149 If p_stage = \*Qthird\*U kill off a bunch of people,
150    alert the owner and the news and decrement p_time by dt.
151    If p_time \*(<= 0 set p_stage = zero (plague has burned itself out).
152 If p_stage = \*Qsecond\*U report
153    to the owner and the news and decrement p_time by dt.
154    If p_time \*(<= 0 set p_stage = \*Qthird\*U
155       and randomly reset p_time in the range of etu_per_update to
156       (etu_per_update * 2).
157 If p_stage = \*Qfirst\*U decrement p_time by dt.
158    If p_time \*(<= 0 set p_stage = \*Qsecond\*U
159       and randomly reset p_time in the range of etu_per_update to
160       (etu_per_update * 2).
161 If p_stage = zero and a random number in the range 0-99
162    is less than the figure generated by the equation in \*Qinfo plague\*U
163    then set p_stage = \*Qfirst\*U
164    and set p_time to a random number in the range of etu_per_update to
165    (etu_per_update * 2).
166 .s1
167 /* delivery & distribution */
168 If anything is being delivered from this sector and there is
169 more of it than the delivery threshold (always a multiple of 8)
170 and the country is not broke
171     deliver as much of the excess as mobility allows.
172     If plague_stage is \*Qsecond\*U (the infectious stage)
173         set plague_stage and plague_time in the destination sector.
174 If there is a \*Qdistribution threshold\*U for this sector, and
175 if the sector isn't at this threshold,
176         import or export as necessary from the distribution warehouse
177         the number of commodities, mobility permitting.
178
179 /* production */
180 If effic is less than 60 skip the rest.
181 .in +3
182 .s1
183 .ti -3
184 If desig is bank then accrue  etu * bankint  interest per gold bar
185 .ti -3
186 If desig is capital pay etu * $1 for government salaries
187 .ti -3
188 If desig is enlistment sector, then convert civilians to military
189         newmil = (etu * (mil + 10) * 0.05);
190         nat_money -= newmil * 3;
191 .ti -3
192 If this sector produces something (mines, research labs, etc.)
193    calculate how much can be produced (see \*Qinfo Products\*U)
194        (Note that the amount that can be produced is limited by \*Qwork\*U)
195    produce it
196    pay for it (money, iron, gold mineral, oil, etc.)
197 .fi
198 .in \\n(in
199 .s1
200 Several points are noteworthy:
201 .s1
202 \(bu The work done in a sector (ore dug up, efficiency growth,
203 population growth, products generated, etc) is dependent on the
204 product of time since last update and work force (\*Qwork\*U above)
205 while the accumulation of mobility is independent of work force.
206 .s1
207 \(bu If the population of a sector is very low it may never generate
208 any work at all due to conversion to integer truncation.
209 .s1
210 Ship Updates
211 .s1
212 Ships are also updated only when accessed however the mechanism is simpler.
213 The only characteristics that are changed by ship updates are
214 the mobility,
215 the efficiency, (if less than 100%).
216 the food, (and therefore the crew if starvation occurs),
217 the amount of oil,
218 and
219 plague status, (which can also change the size of the crew).
220 .s1
221 The algorithm is essentially:
222 .in +3
223 .nf
224 add etu to mobility (with a maximum of 127)
225 add etu to efficiency (with a maximum of 100)
226 add etu * civil * sector_oil / 10000. to oil if ship type is oil derrick
227 add etu * civil * sector_fertil / 10000. to food if ship type is fishing boat
228 feed the crew and passengers
229     starve a few if not enough food
230 check for plague progress,
231     (the same as in sectors except each stage lasts twice as long on a ship)
232 .fi
233 .in
234 .s1
235 Bureaucratic Time Units
236 .s1
237 There is one further update that is not handled in the sector
238 update routine; that is the update of bureaucracy time units (BTU's).
239 These are the numbers printed in brackets before the command
240 prompt.
241 Most commands given use BTU's, some use 1, some use 2 and some use
242 more, making BTU's a vital commodity.
243 The generation of BTU's is
244 dependent on the efficiency and the work force in the capital sector.
245 (see info BTU).
246 .s1
247 .s1
248 .SA "Education, Happiness, Products, Research, Technology, Time, BTU, Obsolete"