]> git.pond.sub.org Git - empserver/blob - info/Innards.t
m4: Refresh macros from autoconf-archive commit fd1d25c148
[empserver] / info / Innards.t
1 .TH Concept Innards
2 .NA Innards "Some details about the inner workings of the server"
3 .LV Obsolete
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 fgrate
75 the food growth rate
76 .L fcrate
77 the food cultivation rate
78 .L eatrate
79 how much food people eat
80 .L obrate
81 birth rate
82 .L uwbrate
83 uncompensated worker birth rate
84 .L babyeat
85 how much babies eat growing up
86 .L bankint
87 bank interest rate in $/bar
88 .in
89 .nf
90 .s1
91 workforce = (civ*work/100 + uw + mil * 0.4) / 100.
92 If workforce = 0 go away and don't update anything
93
94 /* increase sector efficiency */
95 If the weather is good enough for construction and we're not broke then
96   effic becomes effic + work (if possible) and costs $1 for each
97   percentage point gained.
98 Otherwise charge the $1 for each percentage point that would have been
99   gained, (pay for workers to play cards).
100
101 /* grow some food */
102 Set dd = etu * sector_fertility * fgrate
103     (this is the amount of food that can be grown in etu time units)
104 Set dtemp = work * 100. * fcrate
105     (this is the amount of food that the people there can harvest)
106 If (dtemp < dd)     (if there aren't enough people to harvest it all)
107     set dd = dtemp
108 Set foodtmp to the amount of food in the sector plus dd
109
110 /* feed the masses */
111 If desig is sanctuary then
112     set dd equal to 0.
113 Else
114     set dd equal to etu * (civ + mil) * eatrate
115         (this is the amount of food the people need to eat)
116 If (dd > foodtmp) then some people will starve
117     figure out what percentage of the population can be fed,
118     and kill the rest (up to a maximum of 1/2 the populace)
119     set food = 0
120 Otherwise
121     set food = foodtmp - dd (with a maximum of 999)
122
123 /* population growth */
124 set q = etu * civ * obrate
125         the number of births possible in other sectors
126 If q is bigger than food / (2 * babyeat) set q to food / (2 * babyeat)
127         food available to mature this many babies into civilians
128 If q is bigger than 999 - civ set q to 999 - civ
129         enough room for that many
130 Set food = food - q * babyeat
131 Set civ = civ + q
132
133 /* mobility */
134 Add etu to mobil (to a max of 127)
135
136 /* pay taxes */
137 Collect the taxes, pay the military
138     civ_tax = (int) (.5 + (civs * eff * etu * civtaxrate / 100.));
139     if (conquered) civ_tax /= 4.;
140     uw_tax  = (int) (.5 + (uws  * eff * etu * uwtaxrate  / 100.));
141     mil_pay = (int) (mil * etu * milpayrate);
142
143     nat_money -= mil_pay
144     nat_money += civ_tax + uw_tax
145
146 /* plague */
147 If p_stage = \*Qthird\*U kill off a bunch of people,
148    alert the owner and the news and decrement p_time by dt.
149    If p_time \(<= 0 set p_stage = zero (plague has burned itself out).
150 If p_stage = \*Qsecond\*U report
151    to the owner and the news and decrement p_time by dt.
152    If p_time \(<= 0 set p_stage = \*Qthird\*U
153       and randomly reset p_time in the range of etu_per_update to
154       (etu_per_update * 2).
155 If p_stage = \*Qfirst\*U decrement p_time by dt.
156    If p_time \(<= 0 set p_stage = \*Qsecond\*U
157       and randomly reset p_time in the range of etu_per_update to
158       (etu_per_update * 2).
159 If p_stage = zero and a random number in the range 0-99
160    is less than the figure generated by the equation in \*Qinfo plague\*U
161    then set p_stage = \*Qfirst\*U
162    and set p_time to a random number in the range of etu_per_update to
163    (etu_per_update * 2).
164 .s1
165 /* delivery & distribution */
166 If anything is being delivered from this sector and there is
167 more of it than the delivery threshold (always a multiple of 8)
168 and the country is not broke
169     deliver as much of the excess as mobility allows.
170     If plague_stage is \*Qsecond\*U (the infectious stage)
171         set plague_stage and plague_time in the destination sector.
172 If there is a \*Qdistribution threshold\*U for this sector, and
173 if the sector isn't at this threshold,
174         import or export as necessary from the distribution warehouse
175         the number of commodities, mobility permitting.
176
177 /* production */
178 If effic is less than 60 skip the rest.
179 .in +3
180 .s1
181 .ti -3
182 If desig is bank then accrue  etu * bankint  interest per gold bar
183 .ti -3
184 If desig is capital pay etu * $1 for government salaries
185 .ti -3
186 If desig is enlistment sector, then convert civilians to military
187         newmil = (etu * (mil + 10) * 0.05);
188         nat_money -= newmil * 3;
189 .ti -3
190 If this sector produces something (mines, research labs, etc.)
191    calculate how much can be produced (see \*Qinfo Products\*U)
192        (Note that the amount that can be produced is limited by \*Qwork\*U)
193    produce it
194    pay for it (money, iron, gold mineral, oil, etc.)
195 .fi
196 .in
197 .s1
198 Several points are noteworthy:
199 .s1
200 \(bu The work done in a sector (ore dug up, efficiency growth,
201 population growth, products generated, etc) is dependent on the
202 product of time since last update and work force (\*Qwork\*U above)
203 while the accumulation of mobility is independent of work force.
204 .s1
205 \(bu If the population of a sector is very low it may never generate
206 any work at all due to conversion to integer truncation.
207 .s1
208 Ship Updates
209 .s1
210 Ships are also updated only when accessed however the mechanism is simpler.
211 The only characteristics that are changed by ship updates are
212 the mobility,
213 the efficiency, (if less than 100%).
214 the food, (and therefore the crew if starvation occurs),
215 the amount of oil,
216 and
217 plague status, (which can also change the size of the crew).
218 .s1
219 The algorithm is essentially:
220 .in +3
221 .nf
222 add etu to mobility (with a maximum of 127)
223 add etu to efficiency (with a maximum of 100)
224 add etu * civil * sector_oil / 10000. to oil if ship type is oil derrick
225 add etu * civil * sector_fertil / 10000. to food if ship type is fishing boat
226 feed the crew and passengers
227     starve a few if not enough food
228 check for plague progress,
229     (the same as in sectors except each stage lasts twice as long on a ship)
230 .fi
231 .in
232 .s1
233 Bureaucratic Time Units
234 .s1
235 There is one further update that is not handled in the sector
236 update routine; that is the update of bureaucracy time units (BTUs).
237 These are the numbers printed in brackets before the command
238 prompt.
239 Most commands given use BTUs, some use 1, some use 2 and some use
240 more, making BTUs a vital commodity.
241 The generation of BTUs is
242 dependent on the efficiency and the work force in the capital sector.
243 (see info BTU).
244 .s1
245 .s1
246 .SA "Education, Happiness, Products, Research, Technology, Time, BTU, Server"