Advanced Economy & Trade Routes

Spirictum

Immortal
Joined
Oct 19, 2007
Messages
3,105
Location
Brazil
Well, I started this topic for more then one reason. Currently there are 3. I was checking the CvCity.cpp Trade Route stuff from Afforess SVN, and I stumbled in the first hint of what Advanced Economy means. And it appeared in this part of the code:

Code:
if (GC.getGameINLINE().isOption(GAMEOPTION_ADVANCED_ECONOMY))
                        {
                                CvPlayer &kOtherPlayer = GET_PLAYER(pOtherCity->getOwnerINLINE());
                                CvPlayer &kPlayer = GET_PLAYER(getOwnerINLINE());
                                for (int iI = 0; iI < GC.getNumCivicOptionInfos(); iI++)
                                {
                                        if (kPlayer.getCivics((CivicOptionTypes)iI) == kOtherPlayer.getCivics((CivicOptionTypes)iI))
                                        {
                                                iModifier += GC.getCivicInfo(kPlayer.getCivics((CivicOptionTypes)iI)).getSharedCivicTradeRouteModifier();
                                        }
                                }
                        }

So it seems if you use Advanced Economy it helps trade routes between Civs with the same civics (but this still doesn't say which civics and how it is done). If anyone may give me a light on the Advanced Economy option I thank you. Anyways I'll keep crunching the code (I'm findind this quite interesting).


And that brings me back to two issues that have been haunting me since my first ideas to change LoR more then a year ago (when I still only played LoR).


First there is an issue with Player Order and Trade Routes. It seems players first in the player order have an advantage compared to players late in the player order. The specifics are hard to understand but what I could understand is that when there is a tie between a foreign city and a domestic city in which will give the best route yield to you, the player order will influence which to pick first. If you are player 0, your domestic cities are picked before foreign cities, while if you are the last, all foreign cities win ties. If you want to truly understand this take a look here: http://realmsbeyond.net/forums/showthread.php?tid=4353&pid=192412#pid192412

The only solution he proposed in this thread is here (http://realmsbeyond.net/forums/showthread.php?tid=4353&pid=192636#pid192636), but it doesn't seem final or tested. And that's all I got on the subject. This was posted to me when I questioned the issue from Trade Routes here on CFC. I hope the devs have the time to take a look on this and say what they think.


And now my final issue with this topic is the gamespeed. I already tried to find this everywhere but I couldn't. It's not now, years after what has happened that I'll find. But I'm pretty sure Embryodead (modder of Sword of Islam RFC) said once that the algorithm to choose Trade Routes is so bad, it's one of the major issues making bigger maps with a big number of civs go slow (If I'm not mistaken, he changed it for his Sengoku mod, and despite having several civs it runs pretty fast). Every turn it checks for every city all the best Trade Routes it can have. It seems something heavy, mostly with 50 civs with 10 cities on average. 500 cities with an increasing number of Trade Routes, as you get more Trade Routes as the game develops.

On this issue I would like to see the opinion of anyone who knows about this topic, because if this is true I would love to check a 'Random approach' just to see how gamespeed is affected on the Biggest and Fullest of games.
 
Anything related to XML is still being considered in Rev 739 (the one I have here). CPP stuff is taken from Afforess SVN, so it is always in the last revision

Well, as I said, here is something new to bring light on this issue:

Code:
if (GC.getGameINLINE().isOption(GAMEOPTION_ADVANCED_ECONOMY))
        {
                int iCivicModifier = getCivicInflation();
                int iProjectModifier = getProjectInflation();
                int iTechInflation = getTechInflation();
                int iBuildingInflation = getBuildingInflation();
                int iHurryInflation = getHurriedCount();
                
                iInflationPerTurnTimes10000 *= std::max(0, 100 + iCivicModifier);
                iInflationPerTurnTimes10000 /= 100;
                
                iInflationPerTurnTimes10000 *= std::max(0, 100 + iProjectModifier);
                iInflationPerTurnTimes10000 /= 100;
                
                iInflationPerTurnTimes10000 *= std::max(0, 100 + iTechInflation);
                iInflationPerTurnTimes10000 /= 100;
                
                iInflationPerTurnTimes10000 *= std::max(0, 100 + iBuildingInflation);
                iInflationPerTurnTimes10000 /= 100;
                
                iInflationPerTurnTimes10000 *= std::max(0, 100 + iHurryInflation);
                iInflationPerTurnTimes10000 /= 100;
        }

This is on CvPlayer.cpp

It seems with Advanced Economy On we apply Civic, Building, Project, Tech and Hurry inflation factors to our Inflation/Turn increment.

But I didn't find how Civic inflation affects this. In the XML the values are equal to the ones available ingame (-10 for Slavery, +5 for Monarchy), but if it's added like this it shouldn't make iInflationPerTurnTimes10000 = 0, because the result of using only Slavery and no other Civic that affects inflation would be -10, that applied to the formula would result in: iInflationTimes10000 * 90 / 100. Previously this variable seems to be calculated normally (like in BtS), and as in BtS we had a growing Inflation forever, the problem can't be there. It should be in this part of Advanced Economy changing the variable's value.

Barter is -100 in the XML, what makes total sense because it would result in iInflationTimes10000 * (100 - 100) / 100 = 0. So I think values are brought here without modification (exactly as they are in the XML).

Trying to find info about Tech Inflation I couldn't find anything valuable. There are only 3 techs with the field <iInflationModifier>: Stock Exchanging, Derivatives and Insurance. Also there is a field called <PrereqGameOption> in these 3 techs with GAMEOPTION_ADVANCED_ECONOMY, so I presume these techs only exist with Advanced Economy? This seems strange. Anyways the values for iInflationModifier on these 3 techs is 0, so it seems this is unused by now.

Making a quick search with Ctrl+F I didn't find anything related to Inflation in BuildingInfos.xml or BuildingClassInfos.xml (that relates to buildings and projects alike).

Hurrying is our last field of changes. Hurrying seems to be related to Civics not only in the code but also ingame. But I'm not sure how it affects Inflation (too hard this one).

But taking a quick look at all of this, something must be wrong. Not only in my game with the Iroquois I'm with 0 Inflation in the renaissance, but also in my new game in rev 739 (that didn't have any revision updates since it's beginning) I have 0 Inflation in the Classical Era, and I've already changed from Barter to Slavery (-100 to -10) long ago. This should have made my inflation start growing, because:
1- By the formula Slavery should let you increase your Inflation by the civics field, while Barter nullify Inflation;
2- Buildings and Projects don't affect this at all;
3- Techs also don't affect it;
4- I can't hurry anything;


BTW, has anyone experienced any non 0 value in the Inflation tab of the Financial Advisor with Advanced Economy On? If yes please bring it here for analysis. If the devs don't have time to see everything, we should try to discover things ourselves, and I'm pretty curious to understand this mod completely and share this knowledge with whoever wants it.
 
Honestly I ended up hating the advanced economy game option, it's completely broken IMO. Inflation is a terrible game mechanic and doesn't make sense because the "gold" in civilization isn't your civilizations currency or a representation of it's GDP. If anything, it is maybe a representation of the tax proceeds from cities, but still it is unclear if that is entirely the case.
 
Honestly I ended up hating the advanced economy game option, it's completely broken IMO. Inflation is a terrible game mechanic and doesn't make sense because the "gold" in civilization isn't your civilizations currency or a representation of it's GDP. If anything, it is maybe a representation of the tax proceeds from cities, but still it is unclear if that is entirely the case.

That was my first impression to Inflation in the game long ago. But somehow in BtS it did balance things a bit. It's concept might be wrong, but it's effect on gameplay seemed good. From my impressions it was heavier on more advanced/bigger civilizations.

I think Inflation, not necessarily with this name, nor necessarily with BtS's implementation or AND's, but something to economically hinder more advanced/bigger civs, must exist. The idea to make it more severe on players who abuse the Hurry Gold option is also quite interesting.

It may be a way to help AND not running so fast, and also make undeveloped civs to catch faster. All games I've seen up to now, civs developed extremely fast compared to the year. My Iroquois game got balanced because I paralyzed the game techer, but England was exploring the oceas before 1000 AD. Noyyau's both games on S&T got a lot fast on the game time too.

But maybe advanced economy is screwing the game. I would like to know why is it always yielding 0, even though it shouldn't.


Oh and BTW Afforess, have you looked on the link I posted before about the Trade Route mechanic? Maybe it's an easy solution to a not so big problem. And about my Random Approach, do you think it would alter the performance of the game a lot or not so?
 
Oh and BTW Afforess, have you looked on the link I posted before about the Trade Route mechanic? Maybe it's an easy solution to a not so big problem. And about my Random Approach, do you think it would alter the performance of the game a lot or not so?

The fix linked to in the forum threads is easy to apply. However, I agree the trade routes code is really, really bad. The time cost of calculating trade routes for a player is N^4, where N is the number of cities the player has. That gets pretty bad once the number of cities gets even moderately large.

Trade routes are another feature I don't really like (and I am glad they seem to have gotten rid of in Civ5). You don't "choose" who you do trade with, and the effects are very hard to quantify or control, but can result in a large amount of income.

Would anyone really miss not having trade routes? If the performance savings were large with games, and we replaced additional trade route modifiers with simpler commerce modifiers, wouldn't that be for the benefit of all?
 
The fix linked to in the forum threads is easy to apply. However, I agree the trade routes code is really, really bad. The time cost of calculating trade routes for a player is N^4, where N is the number of cities the player has. That gets pretty bad once the number of cities gets even moderately large.

Trade routes are another feature I don't really like (and I am glad they seem to have gotten rid of in Civ5). You don't "choose" who you do trade with, and the effects are very hard to quantify or control, but can result in a large amount of income.

Would anyone really miss not having trade routes? If the performance savings were large with games, and we replaced additional trade route modifiers with simpler commerce modifiers, wouldn't that be for the benefit of all?

With all the stuff related to Trade Routes, wouldn't it be better to just have a faster approach? The number of stuff in the game that is related to Trade Routes is so big I think removing the feature will take a lot of time.

I assume Trade Routes are recalc every time a city gets conquered/destroyed, in changing civics that increase/decrease the number of Trade Routes, getting another civ/city into your available TRs destination, and besides that on turn passing of course. Maybe instead of on all turn passings, only from 4 to 4? Like an arbitrary value of turns bigger then 1 to pass until Trade Routes are updated? That would make 1 slow turn and 3 (or other number) fast turns.

I think if you get rid of TRs at all some players may get frustrated because not everyone play in the limit of their pc's capacity. Some people play on Standard maps and don't feel any slowness on the whole game with the highest of graphics.


But to be honest a better way of making the assignment of TRs that isn't that memory consuming would be the best. But I have no idea how it could be done.
 
With all the stuff related to Trade Routes, wouldn't it be better to just have a faster approach? The number of stuff in the game that is related to Trade Routes is so big I think removing the feature will take a lot of time.

Actually no. You could set MAX_TRADE_ROUTES in the global defines to zero. That would turn them off right there! Yes, there are XML variables for them, but those would just need to be migrated. The way trade routes are coded makes it actually very easy to disable.

I think if you get rid of TRs at all some players may get frustrated because not everyone play in the limit of their pc's capacity. Some people play on Standard maps and don't feel any slowness on the whole game with the highest of graphics.

That doesn't solve the fact that trade routes are not a good game mechanic.

Also, don't confuse the fact that resources are available with connected cities with trade routes. Totally separate.
 
I think it would be a large project to balance the removal of trade, but I do agree it isn't a good mechanic. If you're going to go to the effort of rebalancing the game for their lack, I'm sure you'll find a good way to do so.

Although, if you're rebalancing the game for Tall vs Wide anyway, it wouldn't really require extra work.
 
I think it would be a large project to balance the removal of trade, but I do agree it isn't a good mechanic. If you're going to go to the effort of rebalancing the game for their lack, I'm sure you'll find a good way to do so.

Although, if you're rebalancing the game for Tall vs Wide anyway, it wouldn't really require extra work.

Same opinion here. Although the game is balanced pretty good for large maps and speed up to epic. I've yet to test other gamespeeds/mapsizes (and handicap levels)
 
The number of trade routes in a city, as far as I know, depends on (correct me if wrong):
-technologies known
-buildings
-civics

The amount of trade generated by a trade route depends on:
-city size (only the target? or home city as well?)
-civics
-landmass
-buildings

for trade with foreign civs, the amount of trade also depends on:
-years of peace
-free trade agreement


If trade routes are removed, that commerce needs to go somewhere else.
Easy candidates to me seem:
-buildings: add some raw :commerce: to buildings like markets, maybe unlocked by a tech. All the buildings that modify trade route output get those modifiers converted to :commerce:% changes.
-civics: Economy civics will add a certain amount of :commerce: per city, depending on civic, maybe with :commerce:% modifiers as well. So free market gives a lot and communalism very little or none, for example.
-technologies: easy way to boost the :commerce: yield of some buildings (market in the example above). Maybe even to boost the :commerce: yield of the city tile itself, if feasible.
-specialists: we already have the new Magistrate specialists (though I'm not clear on what exactly their commerce represents). Maybe give Merchants some raw :commerce: as well?

What I've no idea how to introduce is :commerce: yields or modifiers based on city size, different landmasses and eventual open borders/free trade agreements with other nations.
 
How about this:
Set TR to 0 as Afforess suggested, then play the game. Find the imbalances, correct for them with Commerce or whatever. Play again, and repeat. Until you're satisfied.
That way, you know where specifically to improve the game on without thinking about TR anymore.
Also, you can use Notepad++ search feature and all TRADE_Route XML items and decide in those places too how to tweak the main entries (buildings, technologies, etc).
 
I think it would be a large project to balance the removal of trade, but I do agree it isn't a good mechanic. If you're going to go to the effort of rebalancing the game for their lack, I'm sure you'll find a good way to do so.

Although, if you're rebalancing the game for Tall vs Wide anyway, it wouldn't really require extra work.

I am wondering if removing inflation + removing trade routes together might make the balancing somewhat more easy. Trade routes tend to have no real value until the mid to later game, around the same time inflation begins to kick in and absorb :gold: gains.

So the lack of inflation means more :gold: in the later game, but the lack of trade routes would mean less :gold: in the later game. I doubt it would be entirely balanced, but it might be close.
 
But Inflation reduces only :gold:, while trade routes provide :commerce:, which can become either :gold: or :science:, so without any other source of :commerce: to replace trade routes, that'd also slow down teching, probably a lot.
Hmm, that might not be so terrible after all. Testing is required.
 
45°38'N-13°47'E;13315279 said:
Well, I'm not sure l like the idea, especially because it's tied to an option. I always use advanced economy, but what about those that don't use it?

Oh I think the "advanced economy" option needs to die. This would be standard behavior we are discussing. Non-optional.

45°38'N-13°47'E;13315283 said:
Not to mention, trade route isn't connected with religions and corporations spreading? And are we sure removing them won't cause other problems, for example with blockade missions?

Don't confuse the "connectedness" and trade routes features of the game. There would be no change to testing if a city is connected with another via a route. That is used for resources, religions, corporations, etc. It is totally unrelated to trade routes.
 
45°38'N-13°47'E;13315283 said:
Not to mention, trade route isn't connected with religions and corporations spreading? And are we sure removing them won't cause other problems, for example with blockade missions?

Now you got my point. It's a bad mechanic indeed, but there are so many features tied to Trade Routes that it would be a major work to change everything that uses it. BTW, Espionage missions also take TRs as part of its formula.

And Trade Routes seem to have a huge impact on the beginning of the game for me, in big mapsizes. E.g. I'm playing a game with Spain (which btw I'll restart because it's on deity and I already got screwed) and having 3 cities (one in an island) the Wheelright was giving me 4 :commerce:/city (2 from Techs, 2 from TRs), which in turn could give an even higher output of other stuff with its modifiers. Trade also gives +1 Trade Route, so my cities had 2 Trade Routes in the beginning of the game. With an oversea city I got the +50% for it, and I was starting to make Harbors (+25% for both TRs). If managed well TRs make a huge difference. Just to remind, Cottages are now a lot worse then they were, so if you don't have lots of :commerce: around you, TRs do have a major impact on the beginning (and with Tech Diffusion being multiplicative, TRs help you catch the leading techers a lot faster).

Not surprisingly in BtS (and probably AND too but I didn't test it) the Great Lighthouse is one of the ways of having a super economy in the early game (the other being the Pyramids, but that was definetly removed in AND). The +2 TRs in the beginning mean you may make new cities until Revolution stops you. If you don't play with revolutions, just make a sizeable army, or pick an easily defendable spot.

Here is what Global Defines have for us:

Code:
<Define>
		<DefineName>INITIAL_TRADE_ROUTES</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
(...)
<Define>
		<DefineName>MAX_TRADE_ROUTES</DefineName>
		<iDefineIntVal>16</iDefineIntVal>
	</Define>
(...)
<Define>
		<DefineName>THEIR_POPULATION_TRADE_PERCENT</DefineName>
		<iDefineIntVal>50</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>CAPITAL_TRADE_MODIFIER</DefineName>
		<iDefineIntVal>25</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>OVERSEAS_TRADE_MODIFIER</DefineName>
		<iDefineIntVal>50</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>FOREIGN_TRADE_MODIFIER</DefineName>
		<iDefineIntVal>100</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>FOREIGN_TRADE_FULL_CREDIT_PEACE_TURNS</DefineName>
		<iDefineIntVal>50</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>OUR_POPULATION_TRADE_MODIFIER</DefineName>
		<iDefineIntVal>5</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>OUR_POPULATION_TRADE_MODIFIER_OFFSET</DefineName>
		<iDefineIntVal>-10</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>TRADE_PROFIT_PERCENT</DefineName>
		<iDefineIntVal>20</iDefineIntVal>
	</Define>

The differences here from BtS are that:
Initial TRs is now 0, instead of 1
Max TRs is now 16 instead of 8
Overseas is now 50%, instead of 100%
Foreign is now 100% instead of 150%
Consequently the % increase/turn of peace with a foreign nation is smaller then before*

*FOREIGN_TRADE_FULL_CREDIT_PEACE_TURNS field means the number of turns in peace that are taken until the max of FOREIGN_TRADE_MODIFIER is achieved. This means that in 50 turns we will have +100% Foreign Modifier in TRs with someone we were at war. So we get +2% each turn (E.g. 25 turns after we did peace we will have routes with him with +50% Foreign Modifier). In BtS it yielded +3% per turn (because the max was 150%, and the number of turns to reach it was also 50)

So the OFFSET in -10 means the 5% increase of population is applied for every pop point our city has above 10. If our city is connected to the capital, put +25% to all TRs in the city. If the other city we have TR with is overseas, +50% to it. Other city population percent and Profit percent are still a mystery to me. There is this article about TRs here in CFC (http://forums.civfanatics.com/showthread.php?t=159047), but it mixes vanilla CIV and BtS info, so take care. And it doesn't make reference to where all the info is stored. I would like to know in which file we may see the TR formula.

Don't confuse the "connectedness" and trade routes features of the game. There would be no change to testing if a city is connected with another via a route. That is used for resources, religions, corporations, etc. It is totally unrelated to trade routes.

What about this?
Code:
<Define>
		<DefineName>ESPIONAGE_CITY_TRADE_ROUTE_MOD</DefineName>
		<iDefineIntVal>-20</iDefineIntVal>
	</Define>

Actually no. You could set MAX_TRADE_ROUTES in the global defines to zero. That would turn them off right there! Yes, there are XML variables for them, but those would just need to be migrated. The way trade routes are coded makes it actually very easy to disable.

When I said it would be hard to change everything, I wasn't saying to test purposes, I said to clean the whole game of TR-related stuff. This means buildings, wonders, civics, UN Stuff, Blockade Mission and other game mechanics (like espionage). Not to mention balance, but that's the least of our problems, because I have to disagree with 45°, the game is not exactly balanced: It may be balanced between players, but not in the game flow. Games go too fast, they should have some ties with the current year, and normally they don't. And it's only balanced between players because of the Tech Diffusion that forces this to happen.


My opinion is that we think on a better solution for Trade Routes then just getting rid of them, because the work to clean the mod of all TR-related stuff will be huge.
 
Now you got my point. It's a bad mechanic indeed, but there are so many features tied to Trade Routes that it would be a major work to change everything that uses it. BTW, Espionage missions also take TRs as part of its formula.

No, they don't. The original programmers of BTS seemed confused on the two themselves. There are two concepts here:

Are cities connected &
What trade routes does a city have

The connectedness is relatively simple compared to trade routes, it is a simple connected graph problem. There are no major performance issues with it.

I think the misunderstand stems from the fact that trade routes require the connectedness test. However whether cities are connected or not is not dependent on trade routes (and the city-connectedness logic is used all over the place, war checks, unit movement, etc). Removing the trade routes from the game would not impact connectedness at all.

And Trade Routes seem to have a huge impact on the beginning of the game for me, in big mapsizes. E.g. I'm playing a game with Spain (which btw I'll restart because it's on deity and I already got screwed) and having 3 cities (one in an island) the Wheelright was giving me 4 :commerce:/city (2 from Techs, 2 from TRs), which in turn could give an even higher output of other stuff with its modifiers. Trade also gives +1 Trade Route, so my cities had 2 Trade Routes in the beginning of the game. With an oversea city I got the +50% for it, and I was starting to make Harbors (+25% for both TRs). If managed well TRs make a huge difference. Just to remind, Cottages are now a lot worse then they were, so if you don't have lots of :commerce: around you, TRs do have a major impact on the beginning (and with Tech Diffusion being multiplicative, TRs help you catch the leading techers a lot faster).

I don't play with early buildings much, but I was always of the opinion they were majorly unbalanced and made the game much too easy. I am all too happy to nerf them.

This means buildings, wonders, civics, UN Stuff, Blockade Mission and other game mechanics (like espionage). Not to mention balance, but that's the least of our problems, because I have to disagree with 45°, the game is not exactly balanced: It may be balanced between players, but not in the game flow. Games go too fast, they should have some ties with the current year, and normally they don't. And it's only balanced between players because of the Tech Diffusion that forces this to happen.


My opinion is that we think on a better solution for Trade Routes then just getting rid of them, because the work to clean the mod of all TR-related stuff will be huge.

Nope. You are conflating two ideas. Espionage, blockages, etc have to do with resource connectness. Not trade routes per-se. It is not so hard as you make it out.
 
You do have to agree that many many strategies will get completely different with TRs going away. You think it's easy/fast to change all buildings that give TRs or TR modifiers? I think this may take a good time. I say hard not for the concept, but for the time it'll take (so many buildings and other stuff that affect TRs directly).

But about espionage, are you really sure? There is this guide of espionage here with this part:

Mission Cost Modifier
We add ESPIONAGE_CITY_TRADE_ROUTE_MOD if the city has trade routes with us

Is this the connectedness you said or is it indeed related to TRs?

To be honest I would be a lot happier with a faster game without TRs, but I think the changes to get rid of all stuff will take much time.

EDIT: Here is the code part of the detektyw post that explains this:

Code:
// Trade Route
if (pCity->isTradeRoute(getID()))
{
iModifier *= 100 + GC.getDefineINT("ESPIONAGE_CITY_TRADE_ROUTE_MOD");
iModifier /= 100;
}
 
Back
Top Bottom