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):
75 seconds per Empire time unit
79 the food cultivation rate
81 how much food people eat
85 uncompensated worker birth rate
87 how much babies eat growing up
89 bank interest rate in $/bar
93 workforce = (civ*100/sector work + uw + mil / 5.) / 100.
94 If workforce = 0 go away and don't update anything
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).
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)
110 Set foodtmp to the amount of food in the sector plus dd
112 /* feed the masses */
113 If desig is sanctuary then
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)
123 set food = foodtmp - dd (with a maximum of 999)
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
136 Add etu to mobil (to a max of 127)
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);
146 nat_money += civ_tax + uw_tax
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).
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.
180 If effic is less than 60 skip the rest.
184 If desig is bank then accrue etu * bankint interest per gold bar
186 If desig is capital pay etu * $1 for government salaries
188 If desig is enlistment sector, then convert civilians to military
189 newmil = (etu * (mil + 10) * 0.05);
190 nat_money -= newmil * 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)
196 pay for it (money, iron, gold mineral, oil, etc.)
200 Several points are noteworthy:
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.
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.
212 Ships are also updated only when accessed however the mechanism is simpler.
213 The only characteristics that are changed by ship updates are
215 the efficiency, (if less than 100%).
216 the food, (and therefore the crew if starvation occurs),
219 plague status, (which can also change the size of the crew).
221 The algorithm is essentially:
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)
235 Bureaucratic Time Units
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
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.
248 .SA "Education, Happiness, Products, Research, Technology, Time, BTU, Obsolete"