2 .NA Innards "Some details about the inner workings of the server"
5 Much of this file is now out-of-date. Correct information may be found
6 in the files Update-sequence and build.
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.)
15 Several characteristics of the Empire game are dependent on
17 mobility, efficiency, mining of ore, generation
18 of production units, etc.
20 An understanding of the calculations
21 involved is often helpful in planning the timing of various
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.
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.
37 Here is an approximate description of the algorithm that is
38 called whenever an update occurs:
41 .in \w'workforce\0\0'u
43 the # of Empire time units in this update
45 civilians in the sector
47 military in the sector
49 uncompensated workers in the sector
51 designation of the sector
53 efficiency of the sector
55 iron mineral content of the sector
57 gold mineral content of the sector
59 technology level of the country
61 research level of the country
63 plague stage in the sector
67 an intermediate variable that represents work potential
69 the amount of work done in the sector
72 Parameters used are (see the \*Qversion\*U command for actual values):
77 the food cultivation rate
79 how much food people eat
83 uncompensated worker birth rate
85 how much babies eat growing up
87 bank interest rate in $/bar
91 workforce = (civ*work/100 + uw + mil * 0.4) / 100.
92 If workforce = 0 go away and don't update anything
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).
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)
108 Set foodtmp to the amount of food in the sector plus dd
110 /* feed the masses */
111 If desig is sanctuary then
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)
121 set food = foodtmp - dd (with a maximum of 999)
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
134 Add etu to mobil (to a max of 127)
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);
144 nat_money += civ_tax + uw_tax
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).
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.
178 If effic is less than 60 skip the rest.
182 If desig is bank then accrue etu * bankint interest per gold bar
184 If desig is capital pay etu * $1 for government salaries
186 If desig is enlistment sector, then convert civilians to military
187 newmil = (etu * (mil + 10) * 0.05);
188 nat_money -= newmil * 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)
194 pay for it (money, iron, gold mineral, oil, etc.)
198 Several points are noteworthy:
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.
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.
210 Ships are also updated only when accessed however the mechanism is simpler.
211 The only characteristics that are changed by ship updates are
213 the efficiency, (if less than 100%).
214 the food, (and therefore the crew if starvation occurs),
217 plague status, (which can also change the size of the crew).
219 The algorithm is essentially:
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)
233 Bureaucratic Time Units
235 There is one further update that is not handled in the sector
236 update routine; that is the update of bureaucracy time units (BTU's).
237 These are the numbers printed in brackets before the command
239 Most commands given use BTU's, some use 1, some use 2 and some use
240 more, making BTU's a vital commodity.
241 The generation of BTU's is
242 dependent on the efficiency and the work force in the capital sector.
246 .SA "Education, Happiness, Products, Research, Technology, Time, BTU, Obsolete"