RANDGEN V1.2a      7/31/95

RANDGEN is a tool for RANDMAX user. If you don't know what randmax is then
RANDGEN will do nothing for you (except causing headaches :-)
RANDGEN is freeware. You may upload it to any bbs or distribute it on the
internet as long as it serves no commercial purpose.

RANDMAX is written by Steffen Pietsch and manages your planets :
It randomizes friendly codes, taxes your natives and builds factories
and mines according to an ini file.

RANDMAX and RANDGEN are utilities for VGA Planets, a multiplayer strategy game
written by Tim Wisseman.


I use randmax to manage all my planets. However, it takes a lot of time
to set up a randmax.ini and it is rather annoying to change your ini
whenever you colonize or conquer a new planet. So I thought it would be a
good idea to make a program that generates a randmax.ini for me.

It may also be useful if you host a game and you have to make a few
caretaker turns because you are looking for a replacement player.

Getting started
If you are familar with RANDMAX then just start RANDGEN (as parameter the
directory where your game data is). It will update your existing randmax.ini,
i.e. it will add a 'second-section' order for all planets that have no
'second-section' order. The old randmax.ini will be renamed to randmax.bak

Please read the section "PHOST and HOST v3.2" if you play with
one of these host versions.

This is version v1.2a.
It will work with randmax v2.d1 or later.

New in version v1.2 :
- new defaults :
  MINETURNS 25 (instead of 30)
  nth 40  (instead of 70)
  DEFENSE 20 (instead of 0)

- "auto change" (randmax special orders are automatically updated)
  related -a and -f switches

- fixed problems :
  (1) Unowned planets get a randmax.ini entry with the race characteristics
      of the race that scans the planet. Earlier randgen versions did
      generate an entry that didn't take into account race-specific tax and
      mining rates.
  (2) The maximum number of mines and factories on planets with valuable
      natives was not correctly calculated if there were mines and factories
      on the planet. Note that there is a new method to calculate the max
      factory/mine number.

New in version 1.1 :
- -d switch for maximum defense
- mnt 20/ mct 20 lines for Borg planets

randgen [DIRECTORY] [options]

where options are
-pNN  : generate only for player NN
-n    : generate new randmax.ini (old will be renamed to randmax.bak)
-a    : disable auto change  (update of section 2 in randmax.ini)
-f    : force auto change of ALL section 2 entries in randmax.ini
-dNNN : add a defense order (dNNN) to every planet
-tNNN : taxrate NNN (default 100)
-mNNN : miningrate NNN (default 100)
-iNNN : income limit for factory maximization (default 170)
-rNNN : income limit for mine reduction (default 40)
-oNNN : time to outmine a planet (default 30)
-gNNN : turns number for population calculation (see below, default 30)
-sNN  : safetax limit for growth method taxation (default 3)

Example :

randgen GAME1 -d50 -t150 -o50 -n

will generate a NEW randmax.ini in the directory GAME1 and use a taxrate
of 150%. It will also add a 'd50' command on every planet and use an
'outmine' time of 50 turns (see below).

Note to the auto change :
RANDGEN will change section 2 entries in randmax.ini. This is useful if
small meteors strike, natives appear and in several other cases.
Entries in sections 1 and 3 are not changed. For description of these
sections see randmax.doc.

There is no update of the mines and factories for planets with valuable
natives (where factories are not maximized). The only how these numbers
could change is through terraforming (with a different maximum native
limit), and auto update here would lead to an increase of the maximum
factory/mine number by 160-170 every turn which is exactly what we want to
avoid on such a planet :-)

If you don't like this then turn it off with the -a switch.
If you want an update of all planets, even the ones with valuable natives,
then use the -f switch.

If both -a and -f switches are specified then the first of them will be
in use.

PHOST and HOST v3.2

There are some things you should keep in mind if you play with these
host versions.

HOST has a 20% tax limit for Borg planets (except for avians). If you
tax higher than 20% the happiness will decrease normally but you get
no extra money. Therefore randgen inserts these limits into the third
section of randmax.ini ("mnt 20" and "mct 20").
PHOST has no such limit so you can delete these orders if you play Borg
in a PHOSTed game.

All HOST v3.2 versions (both HOST and PHOST) have a configurable
maximum income per planet. Future randmax versions will support this
limit so make sure that you add the appropriate line into the third
section of randmax.ini.

How does it work ?

RANDGEN will scan your planet data and your randmax.ini. If it finds a
planet that has no special order (in the second section) then it will
generate a special order for this planet and add it to randmax.ini.

The old randmax.ini will be renamed to randmax.bak

If you select the /n switch then randgen will rename an existing randmax.ini
to randmax.bak and generate a completely new randmax.ini.

The special order for the planet depends on the mineral content and the
natives living on it. RANDGEN will try to order enough mines to get the
minerals out of the planet core in a reasonable time but RANDGEN will also
be careful to build not too many mines in order to keep the natives

The parameters
Here is an explaination for the possible command line parameters.

MINETURNS  : randgen will order enough mines to outmine the planet in
             MINETURNS turns. The default is 30. Please note that usually
             the mineral with the lowest density determines the required
             number of mines so most minerals will be mined out a lot
             earlier (at least if you have enough colonists to build the
             required number of mines).
             The default value is 30 turns.
             You control MINETURNS with the /o switch.

MINEINCOME : If your planet has valuable natives then you might want to
             build fewer mines in order to avoid making them upset.
             If you get more tax at 1% taxrate than MINEINCOME then
             RANDGEN will reduce the number of mines.
             Use the /r switch to change the default of 40 MC.

NOFACT     : Usually it makes sense to maximize your factories because
             you will get more money if you build the factories and sell the
             supplies instead of taking the 1 or 2 percent more tax that
             you can get if you build no factories.
             However, a few natives are valuable enough so that it's useful to
             build no factories at all. I call this limit NOFACT and the
             default value is 170 (because you have to go down 1% for
             every 170 factories you build).
             Change this value with the /i switch.

GROWTURNS  : Imagine you have a nice warm planet with few but good natives.
             On the one hand you can let them grow for some turns. After that
             growth period they may be over the MINEINCOME or NOFACT value
             and you want to build only few or no mines and factories.
             On the other hand you may have only very few natives and they
             would take a very long time to grow to a number that justifies
             it to build few mines or factories.
             So I decided to introduce the parameter that works like this :
             I calculate the income per tax% (to compare it with MINEINCOME
             and NOFACT) for the population that you would get if you let
             your natives grow (0% tax) for GROWTURNS turns. The default is
             30 and you can change it with the /g switch.

SAFETAX    : Randmax offers you to tax the natives with a growth method
             ("n") or at 'safetax' ("t", the highest possible tax rate
             without decreasing the native happiness).
             If the safetax rate is low then you will lose a lot of money
             if you tax the natives with the growth method (a result of Tims
             rounding). If you have a high safetax then the increased growth
             will make up very soon for the lost money.
             The SAFETAX switch decides how to tax the natives :
             if the safetax rate is lower or equal to SAFETAX then RANDGEN
             will tell randmax to use safetax. If the safetax rate is higher
             then RANDGEN will order randmax to use the growth method.
             The default value is 3, configurable with the /s switch.

             Usually randgen will assume the default taxrates and miningrates,
             i.e. 200% tax, 70% mining for Feds and 200% mining for Lizards.
             If you select a different tax/miningrate you do not only change
             the rates, you also force randgen to use this value for all


Here is how RANDGEN makes a special order for a certain planet :

First RANDGEN figures out the number of mines that you need to get all
minerals out of the core in MINETURNS turns.

If there are no natives living on the planet then RANDGEN will order this
number of mines plus maximum factories (even if you have 10 million
colonists it's still better to build factories because you need to decrease
the tax by 1 % for every 240 factories you build. 240 factories give you
240 MC but 10 million colonists give you just 100 MC for 1% tax.

(Note that the factory influence is different for natives and colonists :
You need to reduce the native tax by 1% for every 170 mines or factories
instead of 240 for colonists.)

If natives are living on the planet then RANDGEN will check if it is worth
to reduce the number of factories and mines (only if you are not the Cyborg).
Keep in mind that you have to lower the taxrate by 1% for every 170
factories or mines you build. If you get 100 MC for every percent tax then
you lose 100 MC income per turn if you build 170 mines. Once the planet is
mined out you still lose the 100 MC per turn but get nothing for it.

So RANDGEN figures out how much money you will get for _1_ tax percent
if you let the natives grow for GROWTURNS turns. I call this value the

If the INCOME is higher than MINEINCOME then RANDGEN will reduce the mines
by the factor MINEINCOME/INCOME. Additionally the maximum number of
So the more money you can get the fewer mines RANDGEN will build.
However, if INCOME is lower than NOFACT then RANDGEN will still order
the maximum number of factories ("f").

If INCOME is even higher than NOFACT then RANDGEN will try to keep
the number of factories and mines as low as possible.
How low is 'as low as possible' ? Well, everything depends on the
rounding in Tim's formulas. There is a number of mines and factories
that you can build without losing money ( = be forced to go down by 1%)
but if you build just one factory or mine more then you have to decrease the
RANDGEN calculates the possible population maximum (depending on the
climate) and figures out this number. So you can take as much tax
at maximum population as if you have no mines and factories at all.
If you should have already more factories and mines than this number
then RANDGEN will calculate the number for the highest possible taxrate
at maximum population.
Since it doesn't matter if you build factories or mines RANDGEN will
split these number between the mines and factories depending on existing
structures and mineral content (low minerals cause low mine numbers).

The mine and factory numbers are cut to the highest possible multiple
of 10 (to get nice looking planets :-).

After that RANDGEN decides how to tax natives :
If you have a high safetax value (the tax rate at which the happiness
remains constant) then it's better to tax the natives with the growth
method ("n"). If you have a low safetax (<4) then it is more useful
to tax at safetax ("t") because you will lose a lot of money if you tax the
natives with the growth method (also a result of Tims rounding).
BTW RANDGEN will tax Boviniods always with the 'growth' - method.

RANDGEN won't let the natives grow on Cyborg planets, it will always
try to get as much money out of them as possible ('t40').

- If no -n switch is given then randgen will keep the first and third section
  in the existing randmax.ini.
- randgen will always change existing special orders, EXCEPT orders where
  a number follows the factory build order (f???). This is because these
  numbers won't be changed anyway and if you terraform you'll hurt your
  income by building more factories and mines than necessary if such an
  order is changed.
- defense doesn't influence the happiness of natives and colonists

Related Formulas

Maximum mines/factories/defense
maxmines     = 200+sqrt(clans-200)   (or number of clans if clans<200)
maxfactories = 100+sqrt(clans-100)   (or number of clans if clans<100)
maxdefense   =  50+sqrt(clans-50)    (or number of clans if clans<50)

Maximum population 
maxcolonists = 10,000,000*sin(temperature*pi/100)
maxcolonists = 10,000,000*(temp/100) (only Crystals with 'Crystals like desert')
maxnatives   = 15,600,000*sin(temperature*pi/100) (approx)

I figured them out with host314. These formulas were different with host300f,
so if you use an older host version you will get a different growth.

The growth is cut to 0 if
(a) the happiness is lower than 70
(b) the temperature is arctic or desert (<16 or >84)
(c) the maximum population would be exceeded at the current growth rate
The growth is cut to 0 if
(a) the happiness is lower than 70
(b) the maximum population would be exceeded at the current growth rate

If you play the Crystallines and the 'crystals like desert' switch is on you
will get different growth rates for your colonists :

Natives :
                    - (mines+factories)/200 - tax*.85)
Colonists :
                    - tax*.8 - abs(temp-50)/33)

Disclaimer of warranties
RANDGEN is not warranted in any way.  If you use it you use it at your own
risk. The author is not liable for any damage or loss of data that may
occur during regular usage of RANDGEN.

Author's note

If you have suggestions or if you find bugs then please contact me via email :

spock@berlin.snafu.de (preferred)

You can reach the author of RANDMAX, Steffen Pietsch, at :



Thomas Voigt