#### KrikkitTwo

##### Immortal
The basic Formula for the value of a Trade route seems to be

[(1+F)*(5*(Pop-10))+100+Cap)* (Minimum ([T*50%], [D*70%]))*20%/100]

F is 150% (1.5) if it is a Foreign Trade Route, 0 if domestic
Pop is the Pop of the city Getting the trade route
T is the Pop of the City the Trade Route is With
D is the Distance to the City
Cap is 25 if one of the cities is conected to the Capital, 0 if not
[] indicates rounding down

This is for Overland routes, no Harbors, Tiny map

The 69% for distance is Probably specific to Tiny maps

All the numbers (150% for Foreign, 5* population, -10 population adjustment, 25 for Capital, 50% for partner pop, etc. except the 1 and the 100 are in the XML files)

What this indicates is that on a normal map, once your empire is big enough, and the populations are about 20, then Domestic trade routes can make about 3 commerce, 2 quite easily. Foreign Trade Routes can get to 7 or 8 and don't require your empire to be big just to have sufficiently Distant and large-citied trade Partners.

edited from further analysis results

Checked World info for the other sizes too,

so for
Duel is 80%
Tiny 70% (I discovered I made a distance measuring mistake in my 69% calc, Credit to Roland: I would have missed that)
Small 60%
Standard 50%
Large 40%
Huge 30%

Editing for BTS:
BTS explains it a lot better in that there are 2 components to trade
1.= Base value
Base Vaue is the SMALLER of
Population of Other city/10
AND
Distance to the other City * 15%->40% (Huge->Duel)
but Base Value has a Minimum possible value of 1

2. Modifiers, these are all +% and are added together and then the total is used to modify the base value.
Then the Base Values have % modifiers added, the % modifiers are
+5% for population of the Receiving city over 10
+25% if the receiving city has a connection to the Capital
+3% per turn since your last war with the civ (if it is another civ) [max 150%]
+50% if you have a Harbor
+100% for the ToArtemis
+100% if the other city is on another continent
+100% if it is another civ on another continent AND you have a Customs House

#### Roland Johansen

##### Deity
This looks very good

I did a search for the word 'trade' in the xml-files directory and it produced some interesting data. It seems that you've found some of the same data. You're probably doing a similar thing. I'm just trying to help you a little.

The file GlobalDefines.xml has some interesting modifiers (which you've already found before I got to type this):
CAPITAL_TRADE_MODIFIER (hmm, wonder what that is )
FOREIGN_TRADE_MODIFIER (you F variable, I think)
OUR_POPULATION_TRADE_MODIFIER (this is the value 5 that you've found, I think)
OUR_POPULATION_TRADE_MODIFIER_OFFSET (this is the value -10 that you've found, I think)

The file CIV4WorldInfo.xml has an interesting modifier:

This modifier is dependant on map size and becomes smaller with map size. Probably a modifier that is used to balance the value of trade routes with every map size. Nice, it is 70 at tiny size. Close to your 69% value.

Maybe there are other modifiers. I didn't look through every xml-file. I hope, it is a nice formula that can be determined exactly. Good luck with the research.

edit: I was to late with typing this. You've already found this data.

#### Splaaat

##### Chieftain
Is there any way to determine which cities your cities develop trade routes with, or is it automatic/random?

#### KrikkitTwo

##### Immortal
Automatic, I'm guessing a city compares all the trade routes it can get and takes the best ones (you can affect which ones are available through open borders, Mercantilism, cutting trade routes between your cities)

It probably also goes through your cities from largest, with a bonus for the capital, to smallest (because foreign cities can only be used once so it wants to make sure that the cities that give the most benefit, ie the biggest, get those trade routes.)

From other data, it looks like Harbors are applied Before the rounding (otherwise Harbor Cities would never have trade routes with 2 commerce)

#### ChangHao

##### Long standing Civ-er
so... foreign trade routes <- way to go?
but i hate open borders with AI until i've grabbed all the land i want...
by which time i'll be broke

#### Mebert

##### Chieftain
Mercantilism was a disaster for me. I perfered Free Market.

#### maleen

##### Chieftain
Is a city can only have maximum 4 trade routes?

#### KrikkitTwo

##### Immortal
No it can have as many as 8 (hard coded)... in the actual game, the most it could have is

1(base) +1 (Currency) +2 (Great Lighthouse) +1(airport) +1 (Free Market) +1(Single Currency) = 7... this requires researching Flight and having Someone research Mass Media (to get the UN) while avoiding Corporation.

6 is a more realistically achievable # ,replace the 2 at Great Lighthouse with 1 by researching Corporation

#### MamboJoel

##### Cool.
Krikkitone said:
No it can have as many as 8 (hard coded)... in the actual game, the most it could have is

1(base) +1 (Currency) +2 (Great Lighthouse) +1(airport) +1 (Free Market) +1(Single Currency) = 7... this requires researching Flight and having Someone research Mass Media (to get the UN) while avoiding Corporation.

6 is a more realistically achievable # ,replace the 2 at Great Lighthouse with 1 by researching Corporation

Hehehe LOL++ !

#### Swimmer

##### Chieftain
Thanks i Learned alot from this

#### Excl

##### Warlord
Krikkitone said:
1(base) +1 (Currency) +2 (Great Lighthouse) +1(airport) +1 (Free Market) +1(Single Currency) = 7... this requires researching Flight and having Someone research Mass Media (to get the UN) while avoiding Corporation.

Thanks, I've always been looking for this info, as I never understood how to get trade routes before. So basically you're saying you get you maximum number of trade routes using the above principle ... and then the computer determines which cities best pair up with you, and every city gets trade partners until it all matches up?

I guess the Great Lighthouse is a good wonder to get then since you wind up getting 2 extra commerce sources, which could be the same or better as having two city tiles for free! That's gotta be good for the science.

#### Roland Johansen

##### Deity
Trade routes are very good and foreign trade routes in large cities are really excelent. Before you start maximizing the number of trade routes remember that there's only a limited number of foreign cities and each foreign city can only give one trade route with one of your cities. So if you have a large empire and not many friendly nations to trade with, then the extra trade routes in a city will most likely be domestic trade routes that only produce a modest income. This is still very nice, but it is one of the main reasons that the state property civic is better for large empires than the free market civic (the other reason is of course that it removes city distance upkeep which can be a lot in a large empire).

10 characters.

#### DementedAvenger

##### Prince
Krikkitone said:
No it can have as many as 8 (hard coded)

This limit isn't hard coded. You can edit it in the GlobalDefines XML file.

#### floppymoose

##### Warlord
Newbie is confused. I understand that this formula is about the value of a trade route. And I understand that roads and things like Merchantilism affect your elligibility to get trade routes.

But what I don't understand is, if you are eligible, what is it that initiates a trade route? How can I tell when they happen? I have some cities with trade routes right (foriegn) now, and some without, and yet they are all connected to each other by roads. Is there something I shoud do to influence the creation of a trade route, and a second trade routes, etc.. ????

#### Roland Johansen

##### Deity
You can only have 1 foreign trade route (in your empire) per foreign city. Is that maybe what you're experiencing?

#### floppymoose

##### Warlord
I have fewer cities than all the other civs combined, that's for sure. And we all seem to be connected together on one big continent (I'm playing on the default settings across the board, whatever those are). I have open boarders with most of the other civs. I have anywhere from zero to two foreign trade routes in my cities.

#### KrikkitTwo

##### Immortal
Well because you have 2 trade routes in your cities, Each of your cities can use 2 foreign cities' trade routes to your empire. Those Foregn trade routes are concentrated in your best cities, so that some of your cities can only get the domestic trade routes.

Basically the number of Foreign cities that are connected to your cities through Open border Road/River/Coast are Less than 2x the number of your cities (the total # of trade routes you can get)

#### floppymoose

##### Warlord
Thanks for the responses. This has been a very helpful thread.

Replies
14
Views
754
Replies
7
Views
430
Replies
8
Views
370
Replies
5
Views
360
Replies
12
Views
692