Transport cost calculation proposal

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

TheNumLocker

Private
1 Badges
Nov 7, 2012
19
70
  • Crusader Kings II: The Old Gods
I've been thinking about transport costs and how they could be modelled in Vic3 given what we know of the game. I don't read every thread here so maybe it was already discussed (and solved), please link it if this is the case. I saw this post https://forum.paradoxplaza.com/foru...and-economic-geography.1483618/#post-27691666 which basically outlines the same principle I was thinking about.
I worked with the following assumptions from my understanding of the Dev Diaries:
  1. Goods are not tracked as they travel through the market. The game does not model where a tank of oil is produced and where it is consumed. The disparities between supply and demand influence the good's price but producing more than need will not stockpile and producing less will not prevent consumption (unless the yet-unexplained Shortage mechanics kicks in).
  2. Assuming a state has full infrastructure, the local prices of goods match the market prices. The state can buy and sell with every other state in the market without penalty.

I agree with 1. as a reasonable approximation to make the game run smoothly and intuitively. I'm a bit bothered by 2. because with this simplification we lose a core aspect of the economics of the time. So I've tried to come up with a calculation of transport cost that is reasonably realistic, simple enough, scalable and takes into account that units of goods are not explicitly tracked.

In a nutshell: the local price of a good is not only given by the market price but also by it's transport cost. The transport cost calculation takes the distance between two states d and multiplies it by a transport cost factor w. The distance is measured by the length of the trade route between the two states (also an interesting exercise but not the point here). The weight factor is a monetary weight unique for each country and good. It represents the cost of transporting a unit of good over a unit of distance. For example perishable, bulky or dangerous goods would have high weight because it is more expensive to transport them. Since goods are not explicitly tracked I base my calculation only on the capacity of a distant state to satisfy local consumption. Developers hinted to a similar logic where states that can satisfy their own consumption would get bonuses.

The below (pseudo-) code explains the calculation. Hopefully it should be readable to the few non-IT folks here;)

Python:
stateCurrent # state chosen for below calculation
goodCurrent # good chosen for below calculation
w # transport cost weight of goodCurrent
demand # demand for goodCurrent in the stateCurrent (in units of good)

statesOrdered # list of all states ordered by their distance to the stateCurrent
d # distances from stateCurrent to states in statesOrdered

remaining = demand # yet to be satisfied demand for goodCurrent
transportCost_total = 0 # initialization of the total transport cost

for State s in statesOrdered # iterate through list of states beginning with the closest (stateCurrent always first with d=0)

    capacity_s = s.production(goodCurrent) # production capacity of state s
    contribution_s = min(capacity_s - remaining, capacity_s) # contribution of state s towards consumption in stateCurrent, if remaining is low, the state does not contribute with its full capacity

    transportCost_s = contribution_s  * d_s * w # cost of transporting contribution_s from s to stateCurrent over distance d_s
   
    transportCost_total = transportCost_total + transportCost_s # increment total transport cost
    remaining = remaining - contribution_s # decrement remaining demand for good
   
    if remaining == 0
        exit loop # demand for goodCurrent in stateCurrent has been satisfied
       

price_transport = transportCost_total / demand # divide the total transport cost by the demand to calculate average transport price per unit of goodCurrent
price_local = price_market + price_transport # final local price of goodCurrent in stateCurrent

Let's take and example for calculating the local price of wheat in Bohemia (Austrian market):
  • Wheat has a market price price_market=10 and a transport cost factor of w=1
  • Bohemia has a demand for 100 units of wheat
  • Bohemia has the capacity to produce only 70 wheat
  • Since 70 wheat is produced locally, it bears no additional transport cost
    • First iteration of the loop does not increase transportCost_total since d=0
  • Now we search in the states closest to Bohemia for the remaining 30 wheat
  • Moravia is at a distance of d=2 from Bohemia and produces 20 wheat
    • The cost of transporting the 20 wheat is contribution_s * d * w = 20 * 2 * 1 = 40
  • Lower Austria is at a distance of d=5 from Bohemia and produces 120 wheat
    • Since currently remaining=10, we consider only 10 wheat is provided by Lower Austria to Bohemia
    • The cost of transporting the 10 wheat is contribution_s * d * w = 10 * 5 * 1 = 50
  • The entire demand for Wheat in Bohemia can be satisfied by these three states at a transport cost of transportCost_total = 0+40+50 = 90
  • The average per-unit price of transport is price_transport = transportCost_total / demand = 90/100 = 0.9
  • We can now calculate Bohemia's local price of wheat price_local = price_market + price_transport = 10+0.9 = 10.9

In my opinion, this system could generate interesting and realistic gameplay situations such as:
  1. Major shortcuts, e.g. the Suez canal, could drastically decrease the distance between the core states and the colonies, thus decrease prices of exotic goods.
  2. Players will be incentivised to reduce the transport cost factor by researching new inventions (say refrigerated trains). This would give more interesting options and flavour to the technological gameplay. Unsure how Infrastructure production methods could factor into this...
  3. Low-tech industries could still be competitive in remote locations. Colonial farms with less advanced production methods would still be able to supply the local population (or not, depending on how remote it is). Also technologically less advanced nations could, under certain circumstances, profitably supply major powers' colonies with staple goods.
  4. There could be an interesting trade-off between production methods, especially in the food industries. High-efficiency production of raw food would supply the local population, less efficient but more durable processed food would supply the industrial hinterland. For example, raw fish would be reasonably affordable only in coastal states. However, building canneries (with easily imported steel), would produce canned food with a much lower transport cost factor.
  5. Coal is the driving fuel of industrialization. States near a large deposit would have more profitable factories since they all would consume cheap local coal.

What do you think? I've had this in my head for a week now, feels good to get in "on paper":D

PS: if you are concerned about computational complexity, the algorithm can be scaled down by pooling demands and capacities of states into larger regions, sort of trade nodes. All states inside a node would be considered local and would not pay extra for transport. Imports from further away would be calculated on a node-to-node basis. I could also imagine a layered approach where inside the trade node the distances are calculated between individual states, but the node-to-node calculation is applied when the good cannot be supplied by the local node.
 
  • 15Like
  • 4
  • 3Love
  • 2
Reactions:
I like the approach.
Did you consider supply vs (concurrent) demand?

The general idea is that each region tries to get its demanded goods from producers as close as possible. But what if another consumer gets there first?

Example:
Cn = Consumer n for any given good
Pn = Producer n for any given good
X = Transport nodes that are neither C nor P.

C1 - X - P1 - C2 - X - X - P2

For the sake of simplicity lets assume that each instance of C needs the same amount as each instance of P produces.

So in this example C2 would get its goods from P1 at a transport cost of 1 as P1 is the closest to C2.
However, P1 is also the closest to C1. But as C2 is even closer P1 it is already "depleted" by the demand of C2, so C1 would get its goods from P2 at a cost of 6.
Or would in this scenario C2 get its goods from P2 while C1 draws from P1, which overall would be less expensive (2+3 instead of 1+6)?
Or would both draw from P1 despite not having enough supply?
 
Last edited:
  • 3
  • 1
Reactions:
The general idea is that each region tries to get its demanded goods from producers as close as possible. But what if another consumer gets there first?
I didn't consider "competition" for capacities between states. This is covered by assumption 1. AFAIK the game does not track where the produced good is actually consumed. The calculation only considers "has this state the capacity to cover my demand and what is the transport cost". If demands of other states were also taken into account, the complexity would explode (or another smarter approach could work).

However I think in most cases the desired effect would still be achieved as market prices are determined by supply-demand.

Consider a simplified GB with 4 states (England, Scotland, Wales, Ireland) and no colonies: All states demand 100 wheat but only England produces it with 200 capacity. Using my calculation, England would satisfy its consumption locally and the other 3 will import it from England at a low transport cost. This of course does not add up. However, as the total GB supply is 200 and demand is 400, the market price will be very high, so wheat will be expensive in all states (slightly less so in England).
There are examples where it doesn't work - the GB above with Canada as a breadbasket (supply 500, demand 50): market prices are low because overall supply is lower than demand. But everyone on the Isles still buys cheap English wheat instead of importing from Canada.
 
  • 1Like
Reactions:
There are examples where it doesn't work - the GB above with Canada as a breadbasket (supply 500, demand 50): market prices are low because overall supply is lower than demand. But everyone on the Isles still buys cheap English wheat instead of importing from Canada.
That's exactly my point :)
 
  • 1
Reactions:
What do you think? I've had this in my head for a week now, feels good to get in "on paper":D

I like it! The simplifying assumptions make the problem a lot more tractable.

One question: Who gets the added transport cost payments?

One possible problem: Say you have a state X with neighbouring state Y generating a good that X consumes. Taking into account transport cost, the goods production in Y is competitive (cheaper than getting from the home region). However, the business generating goods in Y is still only paid according to the market price of the good, which may not be enough for them to operate, even though they have paying customers (who would be willing to pay more) right next door.

Basically, if we don't track which goods go where, then every local producer has to be competitive on the whole national market, even if they have a local transport advantage.
 
That's exactly my point :)
Ok I though about it and maybe this adjustment could solve it:

Consider 2 steps of the algorithm: first step same as above, except on the side, each state sums its capacities made available for other states (contribution_s). The ratio between this total contribution and the local production gives a sort of "overcontribution multiplier".
In the second step the demand for capacity to this state is artificially lowered by dividing it by the multiplier to indicate it supplies neighbouring states too. This would force the algorithm to search further, untapped states for free capacities :)

Again example with GB from above:
After the 1st round, it is clear that England clearly oversupplies its neighbour. A total of 400 wheat is "supplied" but only 200 are actually produces - the state is assigned a overcontribution multiplier 2.0.
During the 2nd round, states are not allowed to request 100 wheat from England anymore, but a reduced 100/2=50 demand. They must then search further and import the remaining 50 all the way from Canada.
StateSupplyDemand1st round total contributionovercontribution multiplier2nd round demand in England2nd round total contribution
England2001004002.0100/2.0 = 50200
Scotland01000-100/2.0 = 500
Wales01000-100/2.0 = 500
Ireland01000-100/2.0 = 500
Canada5005050-0250

In reality, multiple iteration of this algorithm would be necessary to stabilize the values - Canada might also become overcontributing. The good news is I don't think it would be necessary to run it many time every week (I think the prices refresh every week). We can just use the multiplier values from the previous week and assume it's good enough (or run it 2-3x if it helps the convergence).

It also has to handle situations where no more Supply is available in the market, but that shouldn't be a big issue.
 
  • 3Like
Reactions:
Ok I though about it and maybe this adjustment could solve it:

Consider 2 steps of the algorithm: first step same as above, except on the side, each state sums its capacities made available for other states (contribution_s). The ratio between this total contribution and the local production gives a sort of "overcontribution multiplier".
In the second step the demand for capacity to this state is artificially lowered by dividing it by the multiplier to indicate it supplies neighbouring states too. This would force the algorithm to search further, untapped states for free capacities :)

Again example with GB from above:
After the 1st round, it is clear that England clearly oversupplies its neighbour. A total of 400 wheat is "supplied" but only 200 are actually produces - the state is assigned a overcontribution multiplier 2.0.
During the 2nd round, states are not allowed to request 100 wheat from England anymore, but a reduced 100/2=50 demand. They must then search further and import the remaining 50 all the way from Canada.
StateSupplyDemand1st round total contributionovercontribution multiplier2nd round demand in England2nd round total contribution
England2001004002.0100/2.0 = 50200
Scotland01000-100/2.0 = 500
Wales01000-100/2.0 = 500
Ireland01000-100/2.0 = 500
Canada5005050-0250

In reality, multiple iteration of this algorithm would be necessary to stabilize the values - Canada might also become overcontributing. The good news is I don't think it would be necessary to run it many time every week (I think the prices refresh every week). We can just use the multiplier values from the previous week and assume it's good enough (or run it 2-3x if it helps the convergence).

It also has to handle situations where no more Supply is available in the market, but that shouldn't be a big issue.
I like that :)
 
One question: Who gets the added transport cost payments?
I don't know :D AFAIK the Infrastructure buildings generate revenue by producing abstracted Transportation "goods". The whole thing would have to be rethought to account for actual transport costs.

One possible problem: Say you have a state X with neighbouring state Y generating a good that X consumes. Taking into account transport cost, the goods production in Y is competitive (cheaper than getting from the home region). However, the business generating goods in Y is still only paid according to the market price of the good, which may not be enough for them to operate, even though they have paying customers (who would be willing to pay more) right next door.
Good point, I haven't thought of that. The sell price is always the same (market price), the buying price has accounts for the extra transport cost... Ideally some sort of price-adjustment where the good is more expensive than market, but cheap enough to still compete with imports from the home region. That would complicate thinks, but probably could be achieved through some iterative approach (such as the one I outlined for capacity competition). That would be hell to optimize and keep stable though :D
 
This is all just for fun, but I enjoy it too. I did an algorithm a while back that did all-pairs-shortest paths with goods in priority order and calculated residual transport capacity after shipping food, then ammunition, and so on. Then the Dev Diary revealed that the game’s using a very simple sytem for the sake of speed. So, approaching in that spirit, the way to make the algorithm run fast on modern computers is to make it parallelizable.

Some Brief Code Review: Calculating an ordered list of states by “distance” from each state (which would not be fixed, but have to change dynamically due to such things as railroad construction and blockades) and then iterating per state per good would be extremely expensive, taking O(MN² log N) time. Searching sequentially in sorted order would not vectorize well. It would probably be better to apply some dynamic-programming techniques.

Precalculation: Given the system described in the Infrastructure Dev Diary, calculate the volume of goods we can ship from each province in the world to each other province in the world and store it in a two-dimensional array maxTrade, where maxTrade[i][j] is the maximum capacity of any trade route between state i and state j. This is the maximum capacity of any path between i and j, and the capacity of a path is the smallest weight of any node on the path, where the weight of a node is its rail capacity if it is shipping by land or its port capacity if it is shipping by water. Alternatively, you could weight each edge of the undirected graph of states to the minimum rail capacity of both nodes if it is a land connection, the minimum port capacity of both nodes if it is a water connection, or the sum of those if it is both. (If you want to calculate transport cost rather than transport capacity, you would instead add the shipping costs at each step rather than find the capacity bottleneck.) Finally, set all diagonal elements (representing a state’s capacity to ship to itself) to some high value.

Crucially, this only needs to run when some state’s transport capacity changes, or when its trade relations change, and it can run in a background thread. It’s a very sparse graph, where most provinces connect only to their own markets (unless the game brings back global trade). You could use something like a best-first search for all-pairs-shortest-paths that always tries the highest-capacity route, generates the table dynamically, and stops if there was already a better route to the given node. In peacetime, that would happen when a port or railroad upgrades, and some Dev Diaries have said there will be some decisions to boost this temporarily. In land warfare, it might be captured, damaged or repaired more often.

A bigger challenge is integrating naval blockades into the system. HoI4-style fleets don’t fit it well, but perhaps you assign commerce raiders and submarines to enemy ports, and they reduce each port’s effective capacity, while the capital ships determine control of the seas. Alternatively, maybe there are predetermined trade routes between pairs of ports, and any ships at war with either the source or destination reduce the capacity of any shipping route that passes through their location. (Much more computationally-intensive, since then the game recalculates trade all over the world whenever any warship moves.) You might implement some version of “transports” from HOI4 by making sunk or interdicted merchant ships reduce the capacity of the port where it sailed (so, Germany launching unrestricted submarine warfare would sink American merchant ships). Either way, it’s tricky to represent something like Denmark or the Netherlands shipping goods destined for Germany in the Great War, but not allowing Germany to get around the British blockade completely. A good compromise might be to blockade an entire market, and allow trade deals with another market to bring in trans-shipments through a neutral port. Germany might then be motivated to try to keep the Netherlands a neutral market so they can buy oil from them, Germany’s enemies might have tools to pressure the Netherlands to cut Germany off, and the Netherlands would have some interesting choices to make.

You could also speed up calculations for particular goods by precalculating bitmaps for which state produces which goods Taking the bitwise and of a vector holding a per-state statistic and the bitmask statesMaking[good] would then filter out all states that do not produce the good. This would only need to be updated when a state changes which good it makes.

Calculating Supply: To determine the best source of a good g using maxTrade, for state s would then be as simple as argmax(statesMaking[g] & maxTrade[s]), that is, find the numeric ID of the state with the best trade route to s, after setting the trade capacity of all states that do not produce good g to zero. If you are calculating transport costs per route, you would do something like argmin((statesMaking[g] & transportCosts[s]) | (~statesMaking[g] & infinity)). This is similar, but sets the transport cost from any state that does not produce the good to infinity and then finds the minimum cost.

To figure out army supply, you might try to find the best supply route from any depot to your army, where depots normally are in port, then compare its capacity to the supply weight of the army. Optionally, you might then deduct those military shipments from the transport capacity of the state that sent the supplies. Depots in wartime buy supplies like civilian buildings and must have a trade route to a supplier to restock.

Each good might have a constant “density” of units shipped per transport point that you could use to determine whether the best trade route for it is over capacity.

This algorithm uses fast, simple vector operations. It handwaves a bit, so as long as you have some trade route open, it doesn’t worry about the “best” trade routes producing only a small quantity or ten different trade routes using the same stretch of railroad. As long as you have a connection to any building that makes the good, this algorithm thinks everything’s fine. This supplements the price-setting algorithm based on total supply and demand orders, and does not replace it.
 
Last edited:
  • 4Like
  • 1
Reactions:
I don't know if the devs skim these threads, but a decent shipping cost system is something that I really hope they consider (it might be at the top of my list for expansion through DLC). I would think that it is necessary to model realistic locations for industry/food production relative to population centers.
 
  • 4
Reactions:
This is all just for fun, but I enjoy it too.
Yes this is basically game design fan-fic :D

Thank you for your proposal, quite elegant.

One issue with all of these calculations is that I'm afraid all the different local prices would be difficult for the player to keep track of. Also the transport cost price tag would probably be quite opaque.. Did it increase because of that blockade? Because I changed production methods in a neighbouring state?
 
One issue with all of these calculations is that I'm afraid all the different local prices would be difficult for the player to keep track of. Also the transport cost price tag would probably be quite opaque.. Did it increase because of that blockade? Because I changed production methods in a neighbouring state?
Map modes. The lost art of Paradox Grand Strategies. ;)

Select either "Transport Cost" or "Local Cost" map mode, select good, and the map would show either the real or predicted cost for that good in different states. Hovering over a state would show a tooltip with a breakdown on the cost modifiers. It would also work as the big test for this system's speed: Could it be used to reasonably calculate a map mode that shows a different color / shade for every potential transport cost / local price?
 
  • 1
Reactions:
I've been thinking about transport costs and how they could be modelled in Vic3 given what we know of the game. I don't read every thread here so maybe it was already discussed (and solved), please link it if this is the case. I saw this post https://forum.paradoxplaza.com/foru...and-economic-geography.1483618/#post-27691666 which basically outlines the same principle I was thinking about.
I worked with the following assumptions from my understanding of the Dev Diaries:
  1. Goods are not tracked as they travel through the market. The game does not model where a tank of oil is produced and where it is consumed. The disparities between supply and demand influence the good's price but producing more than need will not stockpile and producing less will not prevent consumption (unless the yet-unexplained Shortage mechanics kicks in).
  2. Assuming a state has full infrastructure, the local prices of goods match the market prices. The state can buy and sell with every other state in the market without penalty.

I agree with 1. as a reasonable approximation to make the game run smoothly and intuitively. I'm a bit bothered by 2. because with this simplification we lose a core aspect of the economics of the time. So I've tried to come up with a calculation of transport cost that is reasonably realistic, simple enough, scalable and takes into account that units of goods are not explicitly tracked.

In a nutshell: the local price of a good is not only given by the market price but also by it's transport cost. The transport cost calculation takes the distance between two states d and multiplies it by a transport cost factor w. The distance is measured by the length of the trade route between the two states (also an interesting exercise but not the point here). The weight factor is a monetary weight unique for each country and good. It represents the cost of transporting a unit of good over a unit of distance. For example perishable, bulky or dangerous goods would have high weight because it is more expensive to transport them. Since goods are not explicitly tracked I base my calculation only on the capacity of a distant state to satisfy local consumption. Developers hinted to a similar logic where states that can satisfy their own consumption would get bonuses.

The below (pseudo-) code explains the calculation. Hopefully it should be readable to the few non-IT folks here;)

Python:
stateCurrent # state chosen for below calculation
goodCurrent # good chosen for below calculation
w # transport cost weight of goodCurrent
demand # demand for goodCurrent in the stateCurrent (in units of good)

statesOrdered # list of all states ordered by their distance to the stateCurrent
d # distances from stateCurrent to states in statesOrdered

remaining = demand # yet to be satisfied demand for goodCurrent
transportCost_total = 0 # initialization of the total transport cost

for State s in statesOrdered # iterate through list of states beginning with the closest (stateCurrent always first with d=0)

    capacity_s = s.production(goodCurrent) # production capacity of state s
    contribution_s = min(capacity_s - remaining, capacity_s) # contribution of state s towards consumption in stateCurrent, if remaining is low, the state does not contribute with its full capacity

    transportCost_s = contribution_s  * d_s * w # cost of transporting contribution_s from s to stateCurrent over distance d_s
  
    transportCost_total = transportCost_total + transportCost_s # increment total transport cost
    remaining = remaining - contribution_s # decrement remaining demand for good
  
    if remaining == 0
        exit loop # demand for goodCurrent in stateCurrent has been satisfied
      

price_transport = transportCost_total / demand # divide the total transport cost by the demand to calculate average transport price per unit of goodCurrent
price_local = price_market + price_transport # final local price of goodCurrent in stateCurrent

Let's take and example for calculating the local price of wheat in Bohemia (Austrian market):
  • Wheat has a market price price_market=10 and a transport cost factor of w=1
  • Bohemia has a demand for 100 units of wheat
  • Bohemia has the capacity to produce only 70 wheat
  • Since 70 wheat is produced locally, it bears no additional transport cost
    • First iteration of the loop does not increase transportCost_total since d=0
  • Now we search in the states closest to Bohemia for the remaining 30 wheat
  • Moravia is at a distance of d=2 from Bohemia and produces 20 wheat
    • The cost of transporting the 20 wheat is contribution_s * d * w = 20 * 2 * 1 = 40
  • Lower Austria is at a distance of d=5 from Bohemia and produces 120 wheat
    • Since currently remaining=10, we consider only 10 wheat is provided by Lower Austria to Bohemia
    • The cost of transporting the 10 wheat is contribution_s * d * w = 10 * 5 * 1 = 50
  • The entire demand for Wheat in Bohemia can be satisfied by these three states at a transport cost of transportCost_total = 0+40+50 = 90
  • The average per-unit price of transport is price_transport = transportCost_total / demand = 90/100 = 0.9
  • We can now calculate Bohemia's local price of wheat price_local = price_market + price_transport = 10+0.9 = 10.9

In my opinion, this system could generate interesting and realistic gameplay situations such as:
  1. Major shortcuts, e.g. the Suez canal, could drastically decrease the distance between the core states and the colonies, thus decrease prices of exotic goods.
  2. Players will be incentivised to reduce the transport cost factor by researching new inventions (say refrigerated trains). This would give more interesting options and flavour to the technological gameplay. Unsure how Infrastructure production methods could factor into this...
  3. Low-tech industries could still be competitive in remote locations. Colonial farms with less advanced production methods would still be able to supply the local population (or not, depending on how remote it is). Also technologically less advanced nations could, under certain circumstances, profitably supply major powers' colonies with staple goods.
  4. There could be an interesting trade-off between production methods, especially in the food industries. High-efficiency production of raw food would supply the local population, less efficient but more durable processed food would supply the industrial hinterland. For example, raw fish would be reasonably affordable only in coastal states. However, building canneries (with easily imported steel), would produce canned food with a much lower transport cost factor.
  5. Coal is the driving fuel of industrialization. States near a large deposit would have more profitable factories since they all would consume cheap local coal.

What do you think? I've had this in my head for a week now, feels good to get in "on paper":D

PS: if you are concerned about computational complexity, the algorithm can be scaled down by pooling demands and capacities of states into larger regions, sort of trade nodes. All states inside a node would be considered local and would not pay extra for transport. Imports from further away would be calculated on a node-to-node basis. I could also imagine a layered approach where inside the trade node the distances are calculated between individual states, but the node-to-node calculation is applied when the good cannot be supplied by the local node.
I like the idea but I think that the devs philosophy is that tracking good is too hardware expensive. I think the transportation cost will be approximated by the cost to keep the infrastructure and the demand for railroads tickets.
 
  • 1
Reactions:
One issue with all of these calculations is that I'm afraid all the different local prices would be difficult for the player to keep track of. Also the transport cost price tag would probably be quite opaque.. Did it increase because of that blockade? Because I changed production methods in a neighbouring state?

Good question. You got some responses here, but I’ll talk a little about how this could work for my idea.

What the algorithm I gave generates is a matrix of the capacity of each trade route between every pair of states in the game. Combined with sets designating which states produce a certain good or which states contain friendly depots of materièl, this can efficiently calculate where the “best” source of supply is for any state, and the capacity of the supply line.

This would easily lend itself to visualization in several ways:
  • A Logistics mode displaying how much supply each province is capable of receiving from any depot. Perhaps brightness represents the supply level, and color whether the primary source is a direct land connection to your core territory, an overseas port, or an allied country that might leave you high and dry.
  • A Commerce mode displaying the currently-selected province’s capacity to trade with every other province on the map
  • A map showing trade routes, in the form of inbound arrows from every primary source of a good the selected province is shipping in, and outbound arrows showing every state that this province is supplying with some good. Perhaps like the migration maps of I:R.
  • A list of where the province is getting and shipping each of its goods.
  • A map showing each province’s access to a given good.
  • A map of which state is supplying a given good to every province on the map, which would look a lot like the trade-node map of EU3.
Additionally, a backtracking search algorithm to determine route capacity can find the bottleneck on the path, or the complete path, with very little extra effort. (ETA: With the simplified system that only cares about the capacity of the bottleneck along the route, you don’t even need to backtrack, You can greedily explore every node reachable along the best open path, and this will find all reachable nodes in order of route quality.) It’s simply a matter of whether the program wants to set aside enough memory to remember the information. Saving the location of the bottleneck between each pair of cities would take the same amount of memory as the matrix of route capacities. (Keeping the complete route between every pair of cities in memory would be hugely more expensive.) This would let every military unit or state with a shortage of some good display where the bottleneck on its supply chain is. This could be a big help to the player and an even bigger one to the AI.

There are enough unique domain-specific features to this search function that it might be worth exploring in more detail: a spare set of land connections along with a densely-connected subgraph of sea lanes using a different infrastructure; route capacity as a minimum of infrastructure on the nodes along the route, giving the algorithm a triangle inequality to prune the search tree; the symmetry of each route going in both directions; the decision of what to memo-ize; and so on.
 
Last edited:
  • 1
Reactions:
In a nutshell: the local price of a good is not only given by the market price but also by it's transport cost.
So there would be an incentive for local vertical integration (ore, coal, iron, steel, machines...) beyond some gamey +25% throughput :cool:
 
  • 2Like
Reactions:
we must also take into account the influence of products such as cauciu transported from brazil to indonesia to vietnam and all of south america
 
So there would be an incentive for local vertical integration (ore, coal, iron, steel, machines...) beyond some gamey +25% throughput :cool:
In V2 I could just build a lvl1 glass factory and get +12.5% on my lvl 10 distillery, in the purest min-max fashion.
With transport costs, you actually encourage matching local in/output