Hello everyone. I have been busy modding away over the last few days, and I am almost ready to give the next update. I will probably release a new version sometime in the coming week or next. For everyone that is curious, I thought I would give a short description of the major new feature coming with the update I will release soon. The new feature has to do with an all new resource trading system I am implementing. For the upcoming version, only food trading will be implemented, but the trade of other resources will follow the same system.
So without further ado, here is a short description of the new trading system.
-------------------------------------
Food in Settlement Populations
What is food:
In this mod, the population is divided into 4 types, gentry, burghers, freemen and serfs. The growth of these individual populations is determined by their carry capacities. Up until now, the carry capacity of the burghers was determined by the urban carry capacity. The urban carry capacity was simply determined by 1/10 of the rural population (serfs and peasants) minus whatever the gentry in a province consumed. This old system has been removed, and now the burgher carry capacity is determined by the
food in a province.
In many ways, food is very similar to the old urban carry capacity. Just like before, every 10 rural population produce 1 unit of food, and each population of gentry reduces the produced food by 1. The main distinction between the old urban carry capacity and food, is that food persists each year. In other words, the excess food not consumed one year will be retained for the following year, contributing to the available stock in the next year. Part of this retained stock is lost each year though. Further detail is given below.
Another key difference between the old system and the new system is that food is tracked on a per province level. This means that all settlements in a province have access to all the food produced and imported into a province. They will share this stock as their overall carry capacity. In the past, settlements had to first build a provincial import market before getting access to provincial urban carry capacity, but this is no longer a limit.
How is food in a province calculated:
Every year:
- Every 10 serf/freemen population produces 1 food unit
- Every 1 gentry/burgher population consumes 1 food unit
- the amount of food imported from other provinces is added to the supply
- the amount of food exported to other provinces is removed from the supply
- The leftover food in a province is reduced by a certain factor (1/2 by default) to represent the spoilage/waste of excess supply
Trade of food:
From the above points, it is clear that the import and export of food from provinces is very important in determining the supply available, but I have yet to actually explain how trade works. I will now explain how the trade of food is calculated between provinces.
Before I go into any detail on the trade system, I just want to acknowledge the EU IV mod MEIOU and Taxes. I took a lot of inspiration for the new trade system from their trade system described in their 3.0 dev diaries. The system I use is a little bit different in its foundation, and likely a lot different in implementation, but I wouldn't have thought to do things the way I have without seeing their dev diaries.
The first step in the calculation of trade is the calculation of the demand score for each province.The demand score is a value between 0 and 1 that gives a measure of the relative demand for food (i.e. the burgher population) vs the available food. The calculation of this value is simply:
Burgher population/(burgher population + food)
Because food is retained each year and acts as a stock, the food value allows the demand score equation to account for both import and export without the need for any other variables.
The trade between provinces is then calculated. When two provinces trade, the province with the lower demand score will export food to the province with the higher demand score. The amount exported will be calculated by multiplying the difference of the two demand scores by the food of the exporting province. The exported food will then be removed from the supply of the exporting province and added to the supply of the importing province, with the exported food value of the new exporting province and imported food value of the importing province also being increased.
Which provinces trade food:
Not all provinces can trade food with each other, and the trade system is instead linked to the trade post system already in the game. All trade is mediated by provinces with trade posts in them.
Each province with a trade post will trade with all provinces in its trading range, a value based on the buildings in a trade post. Additionally, two provinces that that both have trade posts can trade if they are separated by a distance less than the sum of their trade ranges and if they are on the same trade route, or owned by the same character. This allows complex networks of trade to form as trade posts move food between their neighbouring provinces and each other.
How is wealth extracted from trade:
In addition to the exported and imported food values that are stored when trade is calculated, a trade income value is also calculated. The trade income is calculated by multiplying the traded food by the difference in demand score and then again by the base price of food. This is meant to represent merchants making money from the difference in the price of food in two provinces that results from the difference in demand versus supply. This trade income value is then simply added to the monthly income of the trade post.
This sounds unstable:
The system as I have described it so far would likely be rather unstable, as if one province imports from another one year and exports to the same province the next year, it would increase both the import and export values rather than decreasing the import value as should be done. This would result in import and export values gradually increasing ad infinitum.
To resolve this issue, the imported food, exported food and trade income all decay a certain amount each year. If demand and supply are stable, this will result in the decayed amount being replenished each year by new trade, while also allowing for trade to change if conditions change.
Things I still need to tweak:
The new system works quite well for the new trade route system that limits trade posts to only certain key provinces, but it causes a large slowdown when merchant republics build large numbers of trade posts. I will likely tweak the trade range buildings and prevent high level trade range buildings being built in neighbouring provinces in order to reduce the number of provinces that trade posts will trade with, but I am open to other ideas people have of how to determine which provinces should be able to trade with each other.
With this system being so closely linked to trade posts, it is also important that trade posts can be built over most of the map, something that is currently not the case. I plan to release a minor optional addition to this mod that adds trade routes in other parts of the map to deal with this issue. Once I have added more trade resources, I plan on removing all other sources of income from trade posts, so I decided to make my own trade route mod in order to have a clean base with no artificial sources of income for trade routes.
----------------------------------
To show an example of the trade system in action, I have attached a screenshot showing the trade details for the province of Genoa in a test game of mine. You can see that Genoa is importing a large amount of food (8 each year, which is enough to support 8k burghers), but it is also exporting more than half of that imported food. Genoa is acting as an intermediary in a trade network between the supply producing provinces around it and another province with high demand. This large amount of trade provides a large amount of trade income that can be seen added to the trade post income under the heading Genoa: Trade income.
Note, the trade income is added using a province modifier, and so there are finite divisions of the trade income that can be added. That is why the trade income in the trade post is only 9 whereas the calculated value is 9.716.
View attachment 518626
The income from trade and such are still being balanced, so don't take the exact values too seriously just yet.