-#include <config.h>
-
-/* define ORE 1 to add resources, define ORE 0 if you want to use another
- program to add the resources */
-static int ORE = 1;
-static int quiet = 0;
-
-/* If you don't specify these command line arguments, then these are the
- defaults */
-#define DEFAULT_SPIKE 10
-#define DEFAULT_MOUNTAIN 0
-#define DEFAULT_CONTDIST 2
-#define DEFAULT_ISLDIST 1
-
-/* The following five numbers refer to elevation under which (in the case of
- fertility or oil) or over which (in the case of iron, gold, and uranium)
- sectors with that elevation will contain that resource. Elevation ranges
- from 0 to 100 */
-
-/* raise FERT_MAX for more fertility */
-#define FERT_MAX 56
-
-/* raise OIL_MAX for more oil */
-#define OIL_MAX 33
-
-/* lower IRON_MIN for more iron */
-#define IRON_MIN 22
-
-/* lower GOLD_MIN for more gold */
-#define GOLD_MIN 36
+/*
+ * How fairland works
+ *
+ * 1. Place capitals
+ *
+ * Place the capitals on the torus in such a way so as to maximize
+ * their distances from one another. This uses the perturbation
+ * technique of calculus of variations.
+ *
+ * 2. Grow start islands ("continents")
+ *
+ * For all continents, add the first sector at the capital's location,
+ * and the second right to it. These are the capital sectors. Then
+ * add one sector to each continent in turn, until they have the
+ * specified size.
+ *
+ * Growth uses weighted random sampling to pick one sector from the
+ * set of adjacent sea sectors that aren't too close to another
+ * continent. Growth operates in spiking mode with a chance given by
+ * the spike percentage. When "spiking", a sector's weight increases
+ * with number of adjacent sea sectors. This directs the growth away
+ * from land, resulting in spikes. When not spiking, the weight
+ * increases with the number of adjacent land sectors. This makes the
+ * island more rounded.
+ *
+ * If growing fails due to lack of room, start over. If it fails too
+ * many times, give up and terminate unsuccessfully.
+ *
+ * 3. Place and grow additional islands
+ *
+ * Each continent has a "sphere of influence": the set of sectors
+ * closer to it than to any other continent. Each island is entirely
+ * in one such sphere, and each sphere contains the same number of
+ * islands with the same sizes.
+ *
+ * First, split the specified number of island sectors per continent
+ * randomly into the island sizes. Sort by size so that larger
+ * islands are grown before smaller ones, to give the large ones the
+ * best chance to grow to their planned size.
+ *
+ * Then place one island's first sector into each sphere, using
+ * weighted random sampling with weights favoring sectors away from
+ * land and other spheres. Add one sector to each island in turn,
+ * until they have the intended size. Repeat until the specified
+ * number of islands has been grown.
+ *
+ * If placement fails due to lack of room, start over, just like for
+ * continents.
+ *
+ * Growing works as for continents, except the minimum distance for
+ * additional islands applies, and growing simply stops when any of
+ * the islands being grown lacks the room to grow further. The number
+ * of sectors not grown carries over to the next island size.
+ *
+ * 4. Compute elevation
+ *
+ * First, use a simple random hill algorithm to assign raw elevations:
+ * initialize elevation to zero, then randomly raise circular hills on
+ * land / lower circular depressions at sea. Their size and height
+ * depends on the distance to the coast.
+ *
+ * Then, elevate islands one after the other.
+ *
+ * Set the capitals' elevation to a fixed value. Process the
+ * remaining sectors in order of increasing raw elevation, first
+ * non-mountains, then mountains. Non-mountain elevation starts at 1,
+ * and increases linearly to just below "high" elevation. Mountain
+ * elevation starts at "high" elevation, and increases linearly.
+ *
+ * This gives islands of the same size the same set of elevations.
+ * Larger islands get more and taller mountains.
+ *
+ * Finally, elevate sea: normalize the raw elevations to [-127:-1].
+ *
+ * 5. Set resources
+ *
+ * Sector resources are simple functions of elevation. You can alter
+ * iron_conf[], gold_conf[], fert_conf[], oil_conf[], and uran_conf[]
+ * to customize them.
+ */