# Economy

## Metal

The current economy is based on mex overdrive. Putting energy into a mex results in bonus metal of baseMetal * (-1 + sqrt(1 + energy / 50)). Energy here refers to the energy put into the individual mex.

The amount of metal produced per energy is equal to the derivative of the overdrive function, or baseMetal / 100 sqrt(1 + energy / 50). If the typical mex produces 2 baseMetal, the best possible ratio is 1 metal per 50 energy.

The old metal makers produced 1 metal per 100 energy. The marginal metal output of the overdrive system at 2 baseMetal per mex drops to this efficiency at 150 energy per mex. Assuming 7 mexes, this is 1050 energy.

Currently all mexes receive the same amount of energy regardless of their baseMetal. This means that mexes with poor baseMetal can actually harm the economy.

### Metal Hax

This would allow us to take metal extraction behavior over from the engine:

Possible benefits:

• No more guesswork as to how much metal a mex should extract.
• Gadget can count the total amount of metal on a map. We can even set the total amount of metal to some desired value.

Possible downsides:

• Performance hit.
• This system is completely independent of the engine's metal extractor system. This means that we do not get the benefit of seeing extraction on the metal map and auto-drawn metal extractor circles.

### Overdrive Optimization: Form 1

Suppose the metal output of each mex is of the form

P(x) = m (a + bxp)

where x is the energy being put into a mex, m is the base metal produced by the mex, a is a real number, b is a positive real number, and p is a real number between 0 and 1. When the total metal output of all mexes is at its maximum, dP/dx is the same for all mexes, so that taking an infinitesimal amount of energy from any mex and putting it into another would not change the total metal produced. Let

dP/dx = k = bmpxp - 1

Thus,

xp - 1 = k/bmp

x = (k/bmp)1 / (p - 1)

x = (k/bp)1 / (p - 1) m1 / (1 - p)

Therefore, at the optimal point, x is proportional to m1 / (1 - p); since k, b, and p are the same for all mexes, the constant of proportionality is the same for all mexes. Therefore, we can assign each mex m1 / (1 - p) shares of energy to ensure optimal output.

#### Total Production

The total production under this scheme is then http://trac.caspring.org/wiki Wiki

M(E) = sumi(mi(a + b (Emi1 / (1 - p) / sumj (mj1 / (1 - p)))p))

where M is the total metal produced and E is the total energy put into overdrive. Defining s to be the total number of shares sumj (mj1 / (1 - p)),

= a sumi mi + bEp / sp * sumi (mi1 + p / (1 - p))

= a sumi mi + bEp / sp * sumi (mi1 / (1 - p))

= a sumi mi + bEp / sp * s

= a sumi mi + bEps1 - p

For the special case p = p - 1 = 1/2 and letting r be the total metal sumi mi ,

M(E) = ar + b sqrt(Es)

Since the term ar is independent of energy (a base rate of metal) we may as well define the metal from overdrive without this contribution:

V(E) = b sqrt(Es)

The inverse function (energy required to produce V overdrive metal) is

E(V) = V2/ sb2

The derivative of this function gives the energy to metal ratio at that point:

dE/dV = 2V / sb2 = 2 sqrt(E / s) / b

In the general case,

dE/dV = (p1 - 1/p / b) * (E/s)1 - p

### Overdrive Optimization: Form 2

Suppose we want the diminishing returns is not calculated per-mex, but rather per-metal. Furthermore, suppose we want the optimum to be to distribute energy proportional to a mex's metal output. We can do this with the following form (per-mex):

P(x) = m (a + b(x/m)p)

where a, b, and p are subject to the same constraints as before. Proof:

dP/dx = k = bp(x/m)p - 1

as before, but using our new form,

(x/m)p - 1 = k / bp

x/m = (k / bp)1 / (p - 1)

Again, since k, b, and p are the same for all mexes, this means that x, the optimal energy input to the mex, is proportional to m, the base metal output of the mex.

#### Total Production

The total production is

M(E) = ar + br(E/r)p

whence the overdrive metal is

V(E) = br(E/r)p

The inverse function is

E(V) = r(V/br)1/p

Finally, the differential energy per overdrive metal is

dE/dV = r/brp(V/br)1/p - 1 = 1/bp(V/br)1/p - 1 = 1/bp (E/r)1 - p

Again, we can consider the special case p = 1 - p = 1/2, for which

M(E) = ar + b sqrt(rE)

V(E) = b sqrt(rE)

dE/dV = 2 sqrt(E/r)/b

similar to the first form, but with r in place of s.

The chief difference between the two forms when p = 1/2 is that in the first form, the value of a mex in overdrive is proportional to the square of its base metal, while in the second it is directly proportional. I find this to be more desirable.

### GUI

• Amount of energy used and metal produced by overdrive.
• dE/dV. I would recommend this instead of overall E/M, since generally what I would like to know is how much more metal I would get if I built another fusion, etc.
• Control slider. Perhaps make distance proportional to energy, but ticks proportional to metal?

## Energy

There have been complaints that it's difficult to get enough energy. Possible contributing factors:

• The cost standardization was made using 1M:10E, which is higher than many units' old ratios.
• Workers produce much less energy than they used to. For example, armck produces 0.12 E, where it would have produced 1 before (after the rescale).
• It now costs energy to get energy, wheras previously it cost less or no energy, allowing you to expand E with only BP and M.

## Asymptotic Behavior

When economic production is proportional to the amount of resources invested in it, you get exponential growth. In symbolic terms, if R is the amount of resources, and production is given by 1/k dR/dt for some constant k, then the economy grows as R0et/k, where R0 is the initial amount of resources.

The characteristic growth time k is the time it takes the economy to grow by a factor e = 2.718... assuming all resources go into the economy instantly. Translating this into more familiar terms, the doubling time in seconds is equal to

32/30 * ln(2) * cost to get 1 income

~ 0.739 * cost to get 1 income

This holds as long as "cost" and "income" are measured in the same units.

When economic production is proportional to the square root of the resources invested, you get linear growth.

When economic production is proportional to the logarithm of the resources invested, you get a "brick wall" effect: the economy essentially stops growing after a while.

### Examples

Old CA MM economy: 6 minutes, 10 seconds.

• ~20 energy for a 100 metal investment.
• Cost of metal makers is negligible.
• 100 energy makes 1 metal.
• This means it takes 500 metal to get 1 metal production, resulting in a doubling time of 6 minutes, 10 seconds.

CA r2126 worker spam: 12 minutes, 19 seconds.

• Worker costs 20 metal, energy per worker time.
• Resource production is 2% of worker time.
• This means it takes 1000 metal, energy to get 1 metal, energy production resulting in a doubling time of 12 minutes, 19 seconds.

ec0n_spaem.jpg (attatched): 1 minute, 14 seconds.

• Worker costs 20 metal, energy per worker time.
• Resource production is 20% of worker time.
• This means it takes 100 metal, energy to get 1 metal, energy production resulting in a doubling time of 1 minute, 14 seconds.

BA 6.21 T2 MM economy: 3 minutes, 5 seconds.

• 1000 energy + conversion for about a 5000 metal investment.
• 50 energy makes 1 metal.
• This means it takes 250 metal to get 1 metal production, resulting in a doubling time of 3 minutes, 5 seconds.

### Attachments

• metal.lua (4.8 KB) - added by evil4zerggin 21 months ago. Part of a system that would allow us to take over metal extractor behavior from the engine. Probably buggy.
• ec0n_spaem.jpg (32.6 KB) - added by evil4zerggin 21 months ago. 10 minutes, no mexes, with workers producing 20% of their buildpower in resources
• mex_overdrive.png (126.6 KB) - added by CarRepairer 20 months ago. Mex overdrive graph