Rethinking the Trade Routes System

I'm not really sure what AIAndy means with a flood fill algorithm, but my guess is something along this line:
Think of it as a height map where many different factors defines the height of a plot, the lower they are the better they are suited for trade.
Flood fill will start filling the low lying plots by incrementing the "water level" by just a little at a time, effectively tallying up the plots in an order that follows a certain rule-set. It may be global process, or it may have a source plot where it only spreads to plots adjacent to those already filled.
When the plot of one city is "submerged" and it's connected by "water" to another city, these cities will be eligible trade partners.
Those cities that connect the earliest in the process makes for the most natural trade route pairs.

Don't take my word on this though, I'm not a programmer, AIAndy will have to confirm or correct my assumptions.
That is a pretty good explanation of the basics.
The source plots from which the flood starts are all cities and only their "height" is initially determined by some calculation concerning their trade importance. Then that importance is flooded out from the starting points to adjacent plots with easier flooding along roads and rivers so it is somewhat of a trade distance. That is somewhat similar to what realistic culture spread does. If the flood reaches and surrounds another city, then that city is considered trade dominated by the city from which the surrounding flood originated. When two floods meet, then a direct trade connection between the two cities is formed (and the exact plots for the "shortest" connection in terms of trade are also known).
Currently the flooding only stops when the entire map is split up between those spheres of trade influence of each city but I guess it would be easy to cut off the flooding after a maximum trade distance depending on city/tech/something.
 
That is a pretty good explanation of the basics.
The source plots from which the flood starts are all cities and only their "height" is initially determined by some calculation concerning their trade importance. Then that importance is flooded out from the starting points to adjacent plots with easier flooding along roads and rivers so it is somewhat of a trade distance. That is somewhat similar to what realistic culture spread does. If the flood reaches and surrounds another city, then that city is considered trade dominated by the city from which the surrounding flood originated. When two floods meet, then a direct trade connection between the two cities is formed (and the exact plots for the "shortest" connection in terms of trade are also known).
Currently the flooding only stops when the entire map is split up between those spheres of trade influence of each city but I guess it would be easy to cut off the flooding after a maximum trade distance depending on city/tech/something.
I assume that coast is treated the same as rivers as the trade along them is activated by the same tech, if I remember correctly. Oceans and mountains would not spread trade until you get the respective techs.
 
I assume that coast is treated the same as rivers as the trade along them is activated by the same tech, if I remember correctly. Oceans and mountains would not spread trade until you get the respective techs.
Rivers should be at Raft Building, Coast at Sail Making (Name?), Sea at Seafaring, Mountain at Mountaineering and Oceans at Navigation, I think. I don't know if any such techs have been set for the Space Mod terrains.
 
I assume that coast is treated the same as rivers as the trade along them is activated by the same tech, if I remember correctly. Oceans and mountains would not spread trade until you get the respective techs.
I think I based it on the movement cost code so those kind of things are considered.
Also cities are favored for moving trade from land to water and vice versa and borders hinder trade flow, especially if it has to be considered smuggling because of no foreign trade allowed.
 
That is a pretty good explanation of the basics.
The source plots from which the flood starts are all cities and only their "height" is initially determined by some calculation concerning their trade importance. Then that importance is flooded out from the starting points to adjacent plots with easier flooding along roads and rivers so it is somewhat of a trade distance. That is somewhat similar to what realistic culture spread does. If the flood reaches and surrounds another city, then that city is considered trade dominated by the city from which the surrounding flood originated. When two floods meet, then a direct trade connection between the two cities is formed (and the exact plots for the "shortest" connection in terms of trade are also known).
Currently the flooding only stops when the entire map is split up between those spheres of trade influence of each city but I guess it would be easy to cut off the flooding after a maximum trade distance depending on city/tech/something.
This would be an awesome way to establish base default trade routes, then to use units to establish farther, more profitable, hand selected non-default trade routes as discussed.

@Spirictum, are you able to sort out the programming AIAndy left in place there? Do you think you could use it to finish a default trade route method?
 
Using this flood algorithm to handle local Trade Routes? I believe I can, I'll have to take a look at the code first, but even if I can't get it, maybe I can do it from scratch. It seems a good algorithm indeed, a lot more realistic.
 
Using this flood algorithm to handle local Trade Routes? I believe I can, I'll have to take a look at the code first, but even if I can't get it, maybe I can do it from scratch. It seems a good algorithm indeed, a lot more realistic.
Fyi to avoid confusion when reading the code, the resulting graph of the algorithm (not the implementation of it) is stored in a Boost Graph, as I intended to use some of the algorithms available in there for further calculations on the trade graph.
http://www.boost.org/doc/libs/1_32_0/libs/graph/doc/
 
I believe I'll be able to start looking into this this week. I have just done one of my last tests, and I'm just waiting for a teacher to tell me when I'm going to do the next Test and if I'll need more then one.
 
I'm starting my dedication to this today. I have already read a bit the CvTradeNetwork.cpp and I believe I can improve upon that. Using the Boost Graph seems a great idea, I'll gladly work with it, it'll cut a lot of work. So from what I can see, Cities will have 'heights' which are like base factors from which a flooding algorithm will then try to flood out the reach of this city to all tiles in a radial fashion. Aspects will help or hinder this spread in each tile. Tiles under this flood will be considered Dominated by the city from which this flood started.

Each city will attempt this, but from that situation comes 3 scenarios: Floods may touch each other, Floods may overlap each other, Floods may encompass other Cities (other flood sources). Encompassing cities means that those cities are Trade Dominated by the Master City from which the flood originated. Touching Floods create a Trade Route between the cities.

I have yet to read all the file, but I believe those concepts need some input from ideas on how to handle them. Forcing Trade Dominated Cities to not gain much from the Trade Network, and Dominating cities to prosper seems a great idea to me, as it moves the game to specialization of cities. Maybe this could translate directly to the dominated city having only a single route with its master and nothing more, while the master has routes to each city it dominates.

Also not sure if there's already something about this in the code, but the concept of competing floods has to be decided early on I believe. Will floods compete for tiles, or will each flood spread as far as it can ignoring overlapping, and each tile will have an influence of each flood?

This way it can let weaker cities be able to touch other floods and establish like minor routes (as they happen between at least one Dominated City), a city could be dominated by more then one city and a Master could be dominated by others and vice-versa, which would make the word Master and Domination a little awkward.

I don't know which one seems better, nor if the code is already done in one or another. I like both, and would be eager to implement any. But what I think is the most important now is to get ideas on how to handle these aspects. From my PoV, Competing Floods generate less combinations, so reward should be higher, and Multiple Floods generate more combinations, which make rewards less valuable on average, but allows for a higher complexity in the system. By what I have felt already about C2C's vibes in my 2 years playing this mod (it really doesn't feel that much) is that complexity, diversion and multitude wins over simplicity. I may not have used the best words to describe this, but I believe it can be understood ;) (and I agree with this mindset)


Also, a friend of mine is coming to visit me today and he has graduated in Economics, so I'll talk with him about Trade Routes a bit to see if some insights can be crafted.
 
So my friend has loved the concept of splitting Trade Routes in 2 distinct and independent areas: Long More Profitable Routes delegated to the player (we will have to think how the AI will do that), and Closer More Natural Routes which will follow the Flooding Algorithm. He also loved the concept of the Flooding Algorithm and said it's certainly more accurate then the current system.

Cool... you'll have to help me understand these floods better. I wonder if they can be a useful tool for the ideas project...

The concept is simple, but how to translate the different possibilities which emerge from using this algorithm to the mechanisms we want to simulate in-game is the hard part. Each city spreads influence over its neighboring tiles. This influence reaches a certain point and stops. The more important a city is, the farther its influence spreads to. Tile improvements and features help/hinder this spread (roads for help and peaks for hinder as examples). Simply put, it's just that.

Now, as each city starts its own 'flooding', special situations may occur, and here is where we have to decide what these represent. These situations are: touching floods, overlapping floods and floods encompassing other flood sources (cities).


Some of these situations were already suggested to be tied to mechanics of Trade by AIAndy in this post:
That is a pretty good explanation of the basics.
The source plots from which the flood starts are all cities and only their "height" is initially determined by some calculation concerning their trade importance. Then that importance is flooded out from the starting points to adjacent plots with easier flooding along roads and rivers so it is somewhat of a trade distance. That is somewhat similar to what realistic culture spread does. If the flood reaches and surrounds another city, then that city is considered trade dominated by the city from which the surrounding flood originated. When two floods meet, then a direct trade connection between the two cities is formed (and the exact plots for the "shortest" connection in terms of trade are also known).
Currently the flooding only stops when the entire map is split up between those spheres of trade influence of each city but I guess it would be easy to cut off the flooding after a maximum trade distance depending on city/tech/something.


What I believe needs to be decided early on is which approach we will take about competing floods: If a tile will be dominated by only one flood (and thus one city as its trade master), or if each flood will have its degree of influence over a tile.
 
The problem with long range trade routes in Real Life is that they weren't always that profitable. For example, in the 17th century, the Dutch ruled international trade with the largest merchant fleet in the world. However, historical analysis showed that three quarters of profits came from trade with the close by Baltic sea area. The Dutch also shipped exotic goods like spices and Chinaware from the Far East to Europe. However, transporting goods with rickety wooden ships over such distances, through seas filled with storms and pirates, which caused many lost ships, and the need to build and garrison trade posts along the route for replenishment of ships was very expensive, and this ate up a significant part of the profits.
 
The problem with long range trade routes in Real Life is that they weren't always that profitable. For example, in the 17th century, the Dutch ruled international trade with the largest merchant fleet in the world. However, historical analysis showed that three quarters of profits came from trade with the close by Baltic sea area. The Dutch also shipped exotic goods like spices and Chinaware from the Far East to Europe. However, transporting goods with rickety wooden ships over such distances, through seas filled with storms and pirates, which caused many lost ships, and the need to build and garrison trade posts along the route for replenishment of ships was very expensive, and this ate up a significant part of the profits.

Interesting analysis there, and I believe that this will be represented by this new Trade Routes System, because if those long routes are much less in number then local routes, then if all local routes are summed, they will yield a lot more then those long routes. But comparing one by one, the long route will be more profitable then a single local route. It seems to perfectly copy that RL situation you brought IMO.
 
The problem with long range trade routes in Real Life is that they weren't always that profitable. For example, in the 17th century, the Dutch ruled international trade with the largest merchant fleet in the world. However, historical analysis showed that three quarters of profits came from trade with the close by Baltic sea area. The Dutch also shipped exotic goods like spices and Chinaware from the Far East to Europe. However, transporting goods with rickety wooden ships over such distances, through seas filled with storms and pirates, which caused many lost ships, and the need to build and garrison trade posts along the route for replenishment of ships was very expensive, and this ate up a significant part of the profits.
I think the presumption that far routes are more valuable is on the presumption of differing degrees of resource access assumed at more distant locations making for larger profit margins. But this wouldn't always be the case. We could try to simulate that and probably will eventually but for now, maybe too complex.
 
I think proper solutions would be extremely complex. I think you would need Volumetric Resources at least, perhaps even spreading properties for various goods simulating how much the regions get saturated with these resources. On these grounds proper prices per unit could be calculated (each turn of course), resulting in gain/trade action.

I am not entirely sure a proper 64bit program could handle that.
 
I think proper solutions would be extremely complex. I think you would need Volumetric Resources at least, perhaps even spreading properties for various goods simulating how much the regions get saturated with these resources. On these grounds proper prices per unit could be calculated (each turn of course), resulting in gain/trade action.

I am not entirely sure a proper 64bit program could handle that.
DH and I HAVE been considering volumetric resources. We'll see.
 
Don't forget the dozens or so of additional properties (spreading in all land tiles), calculation of local prices etc., all while keeping turn times down. :)

But seriously, volumetric resources could enhance realism in a very nice way. :thumbsup:
 
Top Bottom