                              Concept : Innards

 This topic contains fairly nitty-gritty descriptions of some of the  underly-
ing mechanisms in the Empire system.  It is not meant for the weak-of-heart or
casual reader.  (And it's usually out of date.)

Sector Updates

Several characteristics of the Empire game are dependent on sector updates  --
mobility, efficiency, mining of ore, generation of production units, etc.

An understanding of the calculations involved is often helpful in planning the
timing of various actions and although it is unlikely that this description is
strictly up to date, it should provide a feel for the overall philosophy.

All commodities in a sector are kept as short integers.   The  program  cannot
have  negative  commodity  values,  so the theoretical capacity of a sector is
32767, while in practice it is actually 9999 in warehouses, and  999  in  most
other  sectors.   While  it is possible to move more commodities than 999 into
the non-warehouse sectors, production of commodities will  not  go  above  the
level  of 999.  So, an update that produces 450 units of iron in a sector that

                              Concept : Innards

already has 800 units can at most add 199 units.

Here is an approximate description of the algorithm that is called whenever an
update occurs:

Variables used are:
     etus  the # of Empire time units in this update
      civ  civilians in the sector
      mil  military in the sector
       uw  uncompensated workers in the sector
    desig  designation of the sector
    effic  efficiency of the sector
    miner  iron mineral content of the sector
     gold  gold mineral content of the sector
  t_level  technology level of the country
  r_level  research level of the country
  p_stage  plague stage in the sector
   p_time  plague stage duration
workforce  an intermediate variable that represents work potential
     work  the amount of work done in the sector

                              Concept : Innards

Parameters used are (see the version command for actual values):
s_p_etu  seconds per Empire time unit
 fgrate  the food growth rate
 fcrate  the food cultivation rate
eatrate  how much food people eat
 obrate  birth rate
uwbrate  uncompensated worker birth rate
babyeat  how much babies eat growing up
bankint  bank interest rate in $/bar

workforce = (civ*100/sector work + uw + mil / 5.) / 100.
If workforce = 0 go away and don't update anything

/* increase sector efficiency */
If the weather is good enough for construction and we're not broke then
  effic becomes effic + work (if possible) and costs $1 for each
  percentage point gained.
Otherwise charge the $1 for each percentage point that would have been
  gained, (pay for workers to play cards).

                              Concept : Innards

/* grow some food */
Set dd = etu * sector_fertility * fgrate
    (this is the amount of food that can be grown in etu time units)
Set dtemp = work * 100. * fcrate
    (this is the amount of food that the people there can harvest)
If (dtemp < dd)     (if there aren't enough people to harvest it all)
    set dd = dtemp
Set foodtmp to the amount of food in the sector plus dd

/* feed the masses */
If desig is sanctuary then
    set dd equal to 0.
Else
    set dd equal to etu * (civ + mil) * eatrate
        (this is the amount of food the people need to eat)
If (dd > foodtmp) then some people will starve
    figure out what percentage of the population can be fed,
    and kill the rest (up to a maximum of 1/2 the populace)
    set food = 0

                              Concept : Innards

Otherwise
    set food = foodtmp - dd (with a maximum of 999)

/* population growth */
set q = etu * civ * obrate
        the number of births possible in other sectors
If q is bigger than food / (2 * babyeat) set q to food / (2 * babyeat)
        food available to mature this many babies into civilians
If q is bigger than 999 - civ set q to 999 - civ
        enough room for that many
Set food = food - q * babyeat
Set civ = civ + q

/* mobility */
Add etu to mobil (to a max of 127)

/* pay taxes */
Collect the taxes, pay the military
    nat_money -= (milcost * mil)
    nat_money += (civtax * civ)

                              Concept : Innards

/* plague */
If p_stage = third kill off a bunch of people,
   alert the owner and the news and decrement p_time by dt.
   If p_time <= 0 set p_stage = zero (plague has burned itself out).
If p_stage = second report
   to the owner and the news and decrement p_time by dt.
   If p_time <= 0 set p_stage = third
      and randomly reset p_time in the range of 32 to 64.
If p_stage = first decrement p_time by dt.
   If p_time <= 0 set p_stage = second
      and randomly reset p_time in the range of 32 to 64.
If p_stage = zero and a random number in the range 0-99
   is less than the figure generated by the equation in info plague
   then set p_stage = first
   and set p_time to a random number of half hours between 32 and 64.

                              Concept : Innards

/* delivery & distribution */
If anything is being delivered from this sector and there is
more of it than the delivery threshold (always a multiple of 8)
and the country is not broke
    deliver as much of the excess as mobility allows.
    If plague_stage is second (the infectious stage)
        set plague_stage and plague_time in the destination sector.
If there is a distribution threshold for this sector, and
if the sector isn't at this threshold,
        import or export as necessary from the distribution warehouse
        the number of commodities, mobility permitting.

/* production */
If effic is less than 60 skip the rest.

If desig is bank then accrue  etu * bankint  interest per gold bar
If desig is capital pay etu * $1 for government salaries
If desig is enlistment sector, then convert civilians to military
           newmil = (etu * (mil + 10) * 0.05);
           nat_money -= newmil * 3;

                              Concept : Innards

If this sector produces something (mines, research labs, etc.)
      calculate how much can be produced (see info products)
          (Note that the amount that can be produced is limited by work)
      produce it
      pay for it (money, iron, gold mineral, oil, etc.)

Several points are noteworthy:

o+ The work done in a sector (ore dug up, efficiency growth, population growth,
products generated, etc) is dependent on the product of time since last update
and work force (work above) while the accumulation of mobility is  independent
of work force.

o+ If the population of a sector is very low it may never generate any work  at
all due to conversion to integer truncation.

Ship Updates

Ships are also updated only when accessed however the  mechanism  is  simpler.
The  only  characteristics  that are changed by ship updates are the mobility,

                              Concept : Innards

the efficiency, (if less than 100%).  the food, (and  therefore  the  crew  if
starvation  occurs),  the  amount  of  oil, and plague status, (which can also
change the size of the crew).

The algorithm is essentially:
   add etu to mobility (with a maximum of 127)
   add etu to efficiency (with a maximum of 100)
   add etu * civil * sector_oil / 10000. to oil if ship type is oil derrick
   add etu * civil * sector_fertil / 10000. to food if ship type is fishing boat
   feed the crew and passengers
       starve a few if not enough food
   check for plague progress,
       (the same as in sectors except each stage lasts twice as long on a ship)

Bureaucratic Time Units

There is one further update that is not handled in the sector update  routine;
that  is  the update of bureaucracy time units (BTU's).  These are the numbers
printed in brackets before the command prompt.  Most commands given use BTU's,
some use 1, some use 2 and some use more, making BTU's a vital commodity.  The

                              Concept : Innards

generation of BTU's is dependent on the efficiency and the work force  in  the
capital sector.  Note that no capital implies no BTU's.

The relationship governing the accumulation of BTU's is:

   etu = (current time - last login time) / s_p_etu;
   BTU = BTU + etu * civil * effic / 50

Therefore, a 100% capital with 100 civilians gains 96 BTU's a day, while a 30%
capital  with  38  civilians only gains 11 (10.94) BTU's a day.  Note that the
etu calculation is rounded off to the nearest s_p_etu time units, so  if  your
last logoff was less than s_p_etu seconds ago, you will receive no btus.

See also : education, happiness, products, research, technology, time

