How are trade points between cities calculated?

When one sends a caravan (or freight) from city A to city B, one gains research points, gold, and a new trade route that increases both city A's and city B's trade output. From experience, it appears that the amount of research, gold, and trade is correlated with the size of the cities involved, and the distance between the cities (the need to cross an ocean also seems to increase trade points).

The question is: what are the factors that decide how many research points, gold, and trade points will be gained when one sends a caravan to another city?


Solution 1:

The initial bonus is based on the sum of the trade production of each city, times the distance between them, times a "city trade bonus", with various scaling factors applied. Under the default ruleset, the "city trade bonus" is reduced by 33% when you discover "Railroad", and by another 33% when you discover "Flight", for a cumulative penalty of 56%. Crossing oceans or trading with a different civilization doesn't affect this bonus.

The continuing trade bonus is the sum of the sizes of the two cities involved and the distance between them, multiplied by a factor based on the type of trade route. Under the default ruleset, the type bonus is 1 for same owner/same continent, 2 if the owner or continent is different, and 4 if both the owner and continent are different.

(Curiously, on a square-grid map, the "initial bonus" and "continuing trade" calculations use different methods to measure the distance between the cities. The "initial bonus" calculation uses the "Manhattan metric", while the "continuing trade" calculation uses the number of squares covered. For example, if two otherwise-identical cities are both 16 squares away, but one is horizontally distant while the other is diagonally distant, the continuing trade bonus will be the same for both, but the initial bonus for the diagonal city will be twice as large.)