HomeA mathematical analysis of Civilization II

Civ II

At first glance Civ2 might seem too complicated to be amenable to simple algebra. However, it turns out there are some aspects of the game about which it is possible to say something useful.

### The Big Idea

Well, not such a big idea really. The general argument is to consider tax and luxury rates and forget that they can only move in increments of 10%. We consider the little increments in, for example, the tax rates required to pay for maintenance or the luxury rates required to keep a city out of civil disorder caused by each decision we take, on the grounds that it is the aggregate of all these little increments that force us to make the 10% jumps.

Our 'income' each turn is the total number of trade arrows T, created in all our cities. This is 'spent' either as luxuries, science or money. It is assumed that our priorities are

1. Generate enough money to pay for maintenance on all our city improvements.
2. Generate just enough luxuries to keep all our cities out of civil disorder.
3. Spend the rest of the trade on either science or money (to build up a cash reserve) as required.

### Libraries, Universities, Research Labs

Suppose we want to maximise our total science output. We should then preferably spent the 'free' share of the trade (item 3) entirely on science. If we don't want to do that (since we want to build up a cash reserve) then we should spend 'as much possible' of item 3 on science, leaving a fraction spent on producing cash which we're not prepared to reduce any further.

Let the total trade output of our empire be T.
Suppose there is a city within our empire which generates trade T*, and we are considering building within this city an improvement which will multiply its science output by 1+t, but which will require a maintenance cost C

Let the current science rate be rs (0<rs<1)
Thus total science output is Sold = rs T
Suppose we build this improvement, and change the science rate to rs'
Our science output is now Snew = rs' ((T-T*) + (1+t)T*) = rs' (T + tT*)

Now, to pay for the added maintenance we must increase the tax rate by drt T = C (since we either have zero net income or are running a net income which we are not prepared to reduce). The only way we can achieve this is to cut the science rate.

Thus rs'= rs - drt = rs - C/T
Snew = (rs - C/T)(T + tT*) = rs T + t rs T* - C - tC T*/T = Sold + t rs T* - C - C T*/T

Thus we say dS = Snew - Sold = t rs T* - C - tC T*/T

We can get a bound on the t C T*/T term by noting that 0<T*<T
Thus 0<t C T*/T<t C
Thus t rs T* - (1+t) C < dS < t rs T* - C

If our lower bound is positive we can guarantee that building the improvement will increase our science output. If the upper bound is negative we can guarantee that building the improvement will reduce our science output.

Here's the nice part:
rs T* is just the science output of the city before the improvement is built. So we can decide whether our improvement will help just by looking at the city's science output. The science rate and all the other factors that could concievably be relevant turn out not to matter. Let us call the science output of the city S*.
t S* - (1+t)C < dS < t S* - C

Can't help (upper bound negative): S* < C/t
Must help (lower bound positive): S* > C + C/t

 Improvement Science Gain Science Multiplier Cost Library 50% 1.5 1 University 100% 2.0 3 Research Lab 150% 2.5 3

Note that for each improvement 1 + t = (Sci multiplier with)/(Sci multiplier without)

 Improvement t S*(can't help) S*(must help) Library 0.500 2 3 University 0.333 9 12 Research Lab 0.250 12 15

### Marketplaces, Banks, Stock Exchanges

Suppose we just want to make lots of money (and don't care about the luxury increasing effects)

Let the tax rate be rt, the trade in our target city be T* and the potential improvement multiply money by 1 + t and cost C.

Clearly the change in our termly income after building the improvement will be
dM = t rt T* - C

So we should build it if the money generated by the city M* = rt T* is more than C/t. Well, that was nice and easy

 Improvement Money Gain Money Multiplier Cost Marketplace 50% 1.5 1 Bank 100% 2.0 3 Stock Exchange 150% 2.5 4

Note that for each improvement 1 + t = (Money multiplier with)/(Money multiplier without)

 Improvement t M*(should build) Marketplace 0.500 2 Bank 0.333 9 Stock Exchange 0.250 16

### Temples, Colosseums, Cathedrals

What we want to consider is which of luxuries and happiness improvements waste less trade. Each two luxury units make one unhappy citizen content so, if we have trade T in a city we can make N people content with an increase in luxury rate drl such that N = ½m T drl, where m is the luxury multiplication factor associated with marketplaces etc.
m={1,1.5,2,2.5} for {none, Marketplace, Bank, Stock Exchange} respectively.

If we have an improvement which will make N people content and costs C maintenance (and thus an increased tax rate with C = T drt), then it will be superior to luxuries if drt < drl <=> C < 2N/m. We thus have a 'measure of goodness' 2N/m - C

 Improvement N C 2N-C 2N/(1.5)-C N-C 2N/(2.5)-C Temple 2 1 3.00 1.67 1.00 0.60 Colosseum 4 4 4.00 1.33 0.00 -0.80 Cathedral 3 3 3.00 1.00 0.00 -0.60

We thus have the rather surprising result that Colosseums and Cathedrals don't do you any good after you've got a Bank or Stock Exchange.

I've no idea if is this a deliberate joke about Mammon overtaking God, or just the result of Microprose not thinking things through.

### Rush Build cost

This is just a brief experimentally derived[1] explanation for how the rush-build costs work. I could have typed in a big table of all the results I used to derive these but that would have been tedious - just trust me, ok :-)
The base cost in coins for a rush buy where N production points are needed to complete is

• 2N for a building
• 4N for a wonder or spaceship part
• N*( (N/20) + 2) [rounded down] for a unit

If the production box is empty (no resources have yet been spent) the cost is doubled.

### Other Buildings

#### Factory

As all republic players will realise, through rush buying money is production. Even better it's production exactly where you want it. Factories increase production by 50% and have upkeep 4. Even in the best case (buying a building when some resources have already been spent) that 4 gold/turn could only buy 2 production/turn. So factories are worthwhile in cities with production >4 (50% increase, remember).

### Combat Strength

Suppose we have two units fighting it out,
an attacker with attack strength S, hit points H, and firepower F, and
a defender with defence strength s, hit points h, and firepower f.
What is the probability that (say) the attacker wins, and how much damage should the loser expect to suffer?

Just to restate the rules:

1. The units fight a number of rounds until one unit is destroyed
2. Each round either the attacker hits (with probability S/(s+S)) and reduces the defender's hit points by F, or else the defender hits (with probability 1 - S/(s+S) = s/(s+S)) and reduces the attackers's hit points by f
3. The first unit to run out of hit points is destroyed

Well, the obvious thing to do is say:
Clearly the outcome depends only on the ratio S/(s+S), the number of hits needed to destroy the defender, ceil(h/F), and the number of hits needed to destroy the attacker ceil(H/f).
Let the probability that the attacker wins be PS/(S+s)(ceil(h/F)), ceil(H/f)).

We then have the reltionship
Pr(m,n) = rPr(m-1,n) + (1-r)Pr(m,n-1)
Subject to the conditions
Pr(m,0)=1 (m>0)
Pr(0,n)=0 (n>0)

This is all well and good, with the minor drawback that it doesn't have a suitably nice solution[2]. It's a little irritating that the one issue which is blantantly a straightforward mathematical problem is the one which you have to simplify.

Anyway, having failed to solve it properly we now resort to handwaving.

Set P = S/(s+S) , p = s/(s+S)

Suppose that a large number of rounds are played, so that after N turns the attacker has inflicted a damage of approximately PFN and the defender has similarly inflicted roughtly pfN. At this rate, the attacker can survive for H/pf turns and the defender for h/PF.

The attacker wins if H/(pf)>h/(PF) <=> PFH>pfh <=> SFH>sfh

Oooh, lookee. Pretty result.

This leads us to define the Attack Power, Q of a unit as the attack strength times the firepower times the (current) number of hit points, and the defense power likewise. In a combat the unit with the highest power is the one likely to win. This means that by keeping the ADM values the same but giving HP and/or FP >1 for the modern units, Microprose have made these units several times more powerful than in Civ I, which seems to accord with my experience (no more battleships being destroyed by phalanxes etc).

Suppose the attacker wins. Then the combat will have lasted N = h/PF turns, and the attacker will have suffered
dH = pfN = pfh/(PF) = q/(PF) = qH/Q hits.

Thus dH/H = q/Q
So, if you have a higher power than the enemy, you should expect to win, and expect to lose a fraction of your hit points given by the ratio of the enemy's power to yours

1. I could probably have saved time by buying the rip-off Microprose "strategy guide", which apparently lists some of the formulae the game uses. Am I the only person who finds shipping a manual full of vague non-explanations and then charging extra for information about how the game actually works rather rude?

2. Well, at least I don't know of one (and Prof. Weber looked at it briefly an couldn't think of one either).