There have been several postings here over the years which describe formulae for caravan and freight delivery payments. Although most of the factors affecting the amount of payments have been identified, none of these formulae are able to predict the payment amount exactly in all cases. This is due to not recognizing that the order of application of the various bonuses and penalties is important and to the existance of a previously undescribed MapsizeFactor.

The following procedure can be used to accurately calculate caravan and freight delivery payments.

A base payment is first determined from the base trade of each city and the distance between them. The formula for this base payment is:

This payment amount is then modified by a number of bonuses and penalties which must be applied in a specific order to derive the final delivery payment. The order of calculation and other information required is explained in the 10 steps that follow.

[Note about Civ2 math: All Civ2 algorithms which I have investigated use integer math. This means that any remainder left after a division operation is discarded. For example, the result of both 17/8 and 23/8 would be 2. There is no rounding. ]

If the coordinates of point A are (Xa, Ya) and the coordinates of point B are (Xb, Yb), then the absolute difference between Y coordinates is:

Or, in other words, simply subtract the smaller Y value from the larger one.

On a FLAT map, the Xdistance value is found the same way:

On a ROUND map, however, there will be two values which express the horizontal distance between two points: |Xa - Xb| and (

This calculation is easier to do in practice than it is to formally describe.

For example, given two points A(23, 71) and B( 84, 12) on a medium map (50 x 80),

where the circumference is 100:

Ydistance = 71 - 12 = 59.

Xdistance = SmallerOf( 84 - 23 , 100 - (84-23) = SmallerOf( 61, 39) = 39

Distance = (39 + 59)/2 + (|39 - 59|)/4 = 98/2 + 20/4 = 49 + 5 = 54

The

Hides, Salt, Wool, Beads, Copper, Dye 2

Cloth, Coal, Wine, Silver 5/2

Silk, Spice, Gems, Gold 3

Oil 7/2

Uranium 4

Again, the bonuses expressed by fractions are applied by first multiplying by the upper number and then dividing by the lower.

The

Road and Rail bonuses are also used in determining the value of ongoing trade routes. For trade routes each city uses the Source-to-Destination route originating with itself. However, in determining the Road and Rail component of the TransportationBonus, it is the Destination-to-Source route that is used. This is somewhat obtuse and limits the value and frequency of this bonus.

The

The

All applicable transport bonuses are added together to determine the TransportationBonus which is then applied to the result from Step 7.

Some examples:

a) Two cities on the same continent, one has superhighways: 50% bonus = multiplier of 3/2.

b) Two cities connected by railroad via the qualified route, one has superhighways: 150% bonus (rail + SH) = multiplier of 5/2.

c) Two cities on different continents, both have airports and superhighways: 200% bonus = multiplier of 3.

If your civ has acquired

and the applied penalty results in a payment of 12.

The following procedure can be used to accurately calculate caravan and freight delivery payments.

A base payment is first determined from the base trade of each city and the distance between them. The formula for this base payment is:

**Base Payment**= ((**Distance**x**MapSizeFactor**+ 10) x (**Total Base Trade**) ) /24This payment amount is then modified by a number of bonuses and penalties which must be applied in a specific order to derive the final delivery payment. The order of calculation and other information required is explained in the 10 steps that follow.

[Note about Civ2 math: All Civ2 algorithms which I have investigated use integer math. This means that any remainder left after a division operation is discarded. For example, the result of both 17/8 and 23/8 would be 2. There is no rounding. ]

**Step 1)**Calculate the**Distance**between the two cities. The distance between any two points on a Civ2 map can be determined from their X,Y coordinates, where X is a location on the East/West axis, and Y is on the North/South axis. The formula is:**Distance**= (**Xdistance**+**Ydistance**)/2 + ( |**Xdistance - Ydistance**| )/4If the coordinates of point A are (Xa, Ya) and the coordinates of point B are (Xb, Yb), then the absolute difference between Y coordinates is:

**Ydistance**= |Ya - Yb|.Or, in other words, simply subtract the smaller Y value from the larger one.

On a FLAT map, the Xdistance value is found the same way:

**Xdistance**= |Xa - Xb|.On a ROUND map, however, there will be two values which express the horizontal distance between two points: |Xa - Xb| and (

**C**- |Xa - Xb|) where**C**is the circumference of the map. These values represent the X distances between the two points obtained by traveling East or West respectively. The Xdistance value used in calculating Civ2 distances is the smaller of these two numbers. Thus:**Xdistance**= SmallerOf( |Xa - Xb| , (C - |Xa - Xb|) )This calculation is easier to do in practice than it is to formally describe.

For example, given two points A(23, 71) and B( 84, 12) on a medium map (50 x 80),

where the circumference is 100:

Ydistance = 71 - 12 = 59.

Xdistance = SmallerOf( 84 - 23 , 100 - (84-23) = SmallerOf( 61, 39) = 39

Distance = (39 + 59)/2 + (|39 - 59|)/4 = 98/2 + 20/4 = 49 + 5 = 54

**Step 2)**Add the base trade of the two cities. The base trade of a city is determined in the City Display by subtracting any existing trade routes from the total number of trade arrows shown for the city. For a foreign city, the base trade can only be accurately known by investigating the city with a diplomat or spy. However, an estimate can be made from the city size, type of government, and knowledge of the terrain surrounding the city.**TotalBaseTrade**= BaseTrade(City A) + BaseTrade(City B)**Step 3)**Calculate the Base Payment from the formula:**Base Payment**= ((**Distance**x**MapSizeFactor**+ 10) x (**Total Base Trade**) ) /24The

**MapSizeFactor**for a medium map is 1, for a small map it is 5/4, and for a large map it is 4/5. Note that the effect of the MapSizeFactor is that for equal distances, the delivery payments on a small map will be 20% higher than on a medium map and 50% higher than on a large map.**Step 4)**Apply the**TwoContinentBonus**. If the two cities are located on different continents (i.e. they have different continent numbers following their X,Y coordinates in the location field) then*double*the Base Payment derived in step 3.**Step 5)**Apply the**SameCivPenalty**. If the two cities belong to the same civilization, then*halve*the value from Step 4. (Remember when doing this division by 2 to discard any remainder.)**Step 6)**Apply the**FreightBonus**. If the delivery is by freight (as opposed to caravan) multiply the answer from Step 5 by 3/2. i.e., first multiply by 3 then divide by 2, discarding any remainder.**Step 7)**Apply the**DemandBonus**. If the commodity being delivered is demanded by the destination city, then the amount from Step 6 is multiplied by a factor based on the type of commodity involvedHides, Salt, Wool, Beads, Copper, Dye 2

Cloth, Coal, Wine, Silver 5/2

Silk, Spice, Gems, Gold 3

Oil 7/2

Uranium 4

Again, the bonuses expressed by fractions are applied by first multiplying by the upper number and then dividing by the lower.

**Step 8)**Calculate and apply the**TransportationBonus**. Unlike previous bonuses, the**TransportationBonus**consists of several factors which are first combined additively (expressed as a %) before being applied multiplicatively. These are the road, railroad, airport, and superhighways bonuses. Each has peculiarities which will be discussed.The

**Road**(50%) and**Railroad**(100%) bonuses are applied when a valid road or railroad connection exists between the Source and Destination cities. However, determining the specific route required to qualify for the bonus is problematic. First of all, except when the cities are directly aligned on either a North/South or East/West axis, it is likely that the Source-to-Destination route and the Destination-to-Source routes will be different.Road and Rail bonuses are also used in determining the value of ongoing trade routes. For trade routes each city uses the Source-to-Destination route originating with itself. However, in determining the Road and Rail component of the TransportationBonus, it is the Destination-to-Source route that is used. This is somewhat obtuse and limits the value and frequency of this bonus.

The

**Airport**bonus is applied when both cities have an Airport improvement. If the cities are on the same continent, the Airport bonus is 50%. If the cities are on different continents the bonus is 100%. There is no bonus if only one city has an airport.The

**Superhighways**bonus is 50% if only one city has the improvement and 100% if both cities have them. Additionally, of course, Superhighways will increase the BaseTrade of a city substantially, which in turn will increase the Base Payment calculated in Step 3. So Superhighways can appear to produce more than a 50% increase.All applicable transport bonuses are added together to determine the TransportationBonus which is then applied to the result from Step 7.

Some examples:

a) Two cities on the same continent, one has superhighways: 50% bonus = multiplier of 3/2.

b) Two cities connected by railroad via the qualified route, one has superhighways: 150% bonus (rail + SH) = multiplier of 5/2.

c) Two cities on different continents, both have airports and superhighways: 200% bonus = multiplier of 3.

**Step 9)**Determine and apply the**AgeModifier**. The AgeModifier uses 4 key technologies to determine if your civilization is in the Ancient, Renaissance, Industrial, or Modern Age. Since it is possible, via trading with other civs, to acquire later techs without earlier ones, each of the following checks is made in sequence and the modifier applied appropriately.**Invention**and**Navigation**are used to determine if your civ has progressed from Ancient to Renaissance. If you have acquired neither of these technologies and have not yet passed the 200 turns mark, the amount calculated from Steps 1-8 is doubled.If your civ has acquired

**Railroad**, your transition to the Industrial Age causes the payment amount to be reduced by one third. Unlike other modifiers, the 1/3 penalty is applied by dividing the Payment by 3 and then subtracting the result from the Payment. For example, one third of 17 is determined using integer math to be 5and the applied penalty results in a payment of 12.

**Flight**signifies your civ's entry into the Modern Age and causes another 1/3 reduction penalty.**Step 10)**Apply the**ScienceCap**. Delivery of a caravan/freight produces not only a cash payment but, in addition, an equal number of beakers are added to your current research. The Delivery Payment, as calculated in steps 1-9, cannot exceed 2/3 of the total beaker cost (determined at the moment of delivery) of your current research if that cost exceeds 300 beakers. Prior to the 300 beaker point, the ScienceCap is 200 plus a random amount between 0 and 10. At lower tech acquisition levels, it is possible for a single caravan delivery payment to provide more beakers than the total cost of current research. The state of progress of your current research has no effect on the ScienceCap which is based solely on the total cost of research. Whether you need 1 more beaker or the total amount, you will receive all the beakers of the Delivery Payment up to the ScienceCap.
## Comment