• 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.
Hm, If I remember correctly, if you have a variable called myVar in a scope, then in the modifier description you can just use [myVar.GetValue] (Root.myVar.GetValue and This.myVar.GetValue wouldn't work, though).

I gave this a try, but unfortunately nothing displayed, at least for holding modifiers it doesn't seem to work.

EDIT: I just uploaded a new version. It mostly just consists of some bug fixes and tweaks to ai behaviour. I made a change to the way that the levy tracking works as well though. Previously I tracked the total garrison+levy, but that meant that when an occupied settlement was recaptured, it would decrease the population as well. Removing the garrison tracking was the easiest way to fix this, but I am not sure which option is better. Let me know what you guys think.

Following these updates, I will start tweaking the promotion mechanics and add some new laws to control the change of population between peasants, freemen and gentry.

I will also look into modifying the food import mechanic a little bit as well. At the moment, since the import buildings don't remove any of the excess urban capacity away from the settlements in their area, the excess capacity given by the import buildings decreases over time as the other settlements' burgher population grows. I will try to think of a better way of "reserving" carry capacity.
 
Last edited:
I've attached the population breakdown of my holding pretty much just before it depopulated. I hope you can make some sense out of this!
 

Attachments

  • Population Screenshot.jpeg
    Population Screenshot.jpeg
    379,3 KB · Views: 169
So I've noticed this doesn't quite seem to be balanced for shattered world all-tribal games. It seems that population growth in tribal holdings remains really, really slow.

Is there a way to accelerate this that I've missed?
 
Sorry everyone, I have been away for quite some time again. I'm currently finishing up a PhD, and haven't had much time to mod or game at all.

I'm looking in to the problem with the burgher population going negative, but so far I haven't found the cause. If anyone who has had this problem can tell me approximately what their burgher population was before it went negative, it might help.

@sk3, I had a look at your photo. It's clear that the burghers are causing some issue, but I am not sure quite what it is yet. What was your burgher population before it suddenly went negative?
 
Sorry everyone, I have been away for quite some time again. I'm currently finishing up a PhD, and haven't had much time to mod or game at all.

I'm looking in to the problem with the burgher population going negative, but so far I haven't found the cause. If anyone who has had this problem can tell me approximately what their burgher population was before it went negative, it might help.

@sk3, I had a look at your photo. It's clear that the burghers are causing some issue, but I am not sure quite what it is yet. What was your burgher population before it suddenly went negative?

No problem man, go get your PhD and thanks for the work on the mod :)
 
I have yet to find the issue that is causing the exploding burgher populations, but I found an error in the migration code that was making the larger cities lose population to other places. I have uploaded the new version.

I had a little bit of free time this weekend, but I can't foresee when I will be uploading the next update.
 
I updated quite a few things and I believe I fixed all cases exploding population bug.

I haven't had a chance to do all that much playtesting though, so I haven't uploaded the most recent version. I won't have time to make any updates for the next few months, but I can upload the current version, which I have played a few hundred years with and haven't noticed any issues yet.

I'll try to find some time this weekend to upload it.
 
I updated quite a few things and I believe I fixed all cases exploding population bug.

I haven't had a chance to do all that much playtesting though, so I haven't uploaded the most recent version. I won't have time to make any updates for the next few months, but I can upload the current version, which I have played a few hundred years with and haven't noticed any issues yet.

I'll try to find some time this weekend to upload it.

Thanks, would be appreciated.
 
Sorry for not uploading the updated mod on the weekend. Things came up and I couldn't get to it, but I figured I would do it now.

I am still trying to search out and remove bugs in the mod and balance a lot of the new mechanics, so don't expect any new features in any upcoming updates.

If you find any bugs, please let me know.
 
Base populations seem uniformly low across the entire map - it seems like Constantinople has a population of 60k, but literally every other holding has a province of 7-12k, so the tribals end up having about as much economy as Venice. How are initial populations chosen?

I'm playing on Linux, maybe this is a case sensitivity issue?
 
Base populations seem uniformly low across the entire map - it seems like Constantinople has a population of 60k, but literally every other holding has a province of 7-12k, so the tribals end up having about as much economy as Venice. How are initial populations chosen?

I'm playing on Linux, maybe this is a case sensitivity issue?

Sorry for taking a while to respond gallabytes. It is indeed true that the initial populations are rather low. I definitely need to balance the starting populations more. Currently I am trying to finalize all of the mechanics before spending too much time balancing the starting conditions.

Constantinople being 60k is basically a test bed. In the end I hope to give quite a few of the settlements realistic historical population values, but I needed to make sure the code that distributes the excess urban carry capacity properly. Once I finalize various parts of the mod, I plan on giving historical populations to many settlements in the game.

------------------------------

To everyone that is interested in my mod and has been waiting for me to update and expand it, I am very sorry for the long delay and silence. I was fairly busy over the last year until September, and haven't been very active on the forums recently. Fortunately though, I've got more free time again, and though I haven't posted any updates here, I have actually been spending a fair amount of time updating the mod and tweaking a variety of features.

One mechanic that I have never been quite happy with is how excess urban carry capacity is redistributed. In previous versions of my mod, city settlements with a population beyond a certain size could build special buildings that gave them access to the excess carry capacity in their county, duchy and realm, depending on the level of the building. This worked reasonably well to redistribute carry capacity within realms, but it had several limitations.

I decided to completely revamp the system, and have implemented a food trading mechanic that is linked directly to the vanilla trade routes and trade posts. Currently the trade system just deals with the transfer of food, but I eventually plan on creating a more in depth trade system that includes a variety of resources produced by settlements in the game and imported from the silk road. Sometime in the next few days I will post a detailed description of the new system with screenshots and everything.

In the next update, I plan on including the food trade system (not the full system with every resource yet). Before I am ready to release the update though, I need to do some play testing and balancing.
 
We are getting closer to MEIOU mechanics, good good :D

Haha, it is funny that you say that. I actually took a lot of inspiration for the way the food trading works from MEIOU's 3.0 dev diaries. I was surprised to find out though that they didn't have migration in their mod until the upcoming 3.0 version. So I guess I am already ahead of them in some regards.
 
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.

Trade Image.jpg


The income from trade and such are still being balanced, so don't take the exact values too seriously just yet.
 
Last edited:
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.

Reading this really makes me happy. One of these day CK2 might be modded into a game with more historically contingent mechanics.
 
So I have gotten the food trading system to a point where it is now working relatively smoothly, but there are still a lot of balancing issues, missing localizations and other miscellaneous things that need to be fixed.

At the moment, the food should not explode unreasonably, but the long term balance and stability has yet to be tested. I will release the current version (albeit labelled as alpha), but please don't judge it too harshly. I am hoping by releasing this version, people can give me feedback on issues they find with the new food trading system. Unfortunately I don't have enough time to run tons of observe games and properly test the new system.

Along with the new food trading system, I have also uploaded a "Settlement Populations: Trade" submod that adds a bunch of trade routes to the game in order to support the new food trading. It also modifies the saharan and silk road trade routes along with removing nearly all income generated from them. This is necessary because the new trade system allows trade posts in all trade route provinces. In the long run, I plan to revamp the silk road system when I add trade goods and link them to my new trade system.

Note, performance is much slower with these new updates. This is primarily because of the way that the new trade post building triggers work. The "trade post" and "merchant port" trade post buildings determine the maximum land and naval distance, respectively, two trading provinces can be, and for stability reasons, the buildings can only be built when another province with the same level building is at least a certain distance away. The can_land_path_to and can_naval_path to conditions I use to check these are rather computationally intensive, and so this slows the game considerably. Running on a ~5 year old gaming laptop, I am not too bothered by this, but for people with lower grade computers, or who want to blast through a game in less than 3 hours, this might be intolerable.

For the most part, the new food trading system works as described in my previous post, but there are a few changes to which provinces can trade with each other. I will summarize these changes below:

1) Any province with a trade post can trade with all province neighbouring it. This is to resolve the issue of the extremely large provinces in the far east not being able to trade with any other provinces and breaking the trade route trade chains.

2) Trade posts in coastal provinces can build "merchant port" buildings (the same ones that previously only patricians could build). These buildings allow provinces to trade with other coastal provinces within a certain naval distance from them. Higher tiers of this building chain allow provinces to trade with provinces further away.

3) Trade posts that have at least one neighbouring province can build "trade post" buildings. These buildings will replace the "silk road trade post", "saharan route trade post" building chains for specific trade routes. The maximum land distance between the province and provinces it trades with is determined by the level of this building chain.

4) Two provinces with trade posts can trade as long as their naval distance or land distance is within the sum of their maximum naval and land distances, as determined by their "trade post" and "merchant port" building levels.

5) "Trade post" and "merchant post" buildings can not be built in a province if there is another province within the maximum land distance or maximum naval distance allowed by the respective building. This way you will get different tiers of hubs around the map. Right now the building of these buildings is not restricted by anything other than the aforementioned, and therefore, they operate by a first come, first served basis. I may in the future only allow higher tier buildings to be built in provinces with large burgher populations or large trade volumes.

EDIT: I also want to mention another thing. I added to new "fake" mapmodes to display population information and trade information. These new mapmodes use councillor jobs added to the chancellor and steward for the population mapmode and trade mapmode, respectively. They are based off the "fake mapmodes" mod tutorial made by @LordPeter. At the moment they aren't fully fleshed out and I am mostly just using them for debugging, but I plan on expanding them in the future. I want to thank LordPeter for coming up with this idea and sharing it with the community. It is extremely useful for displaying information on new mechanics like the ones added by this mod.

EDIT2: I just uploaded the new alpha version. I will update the OP once I have some time in the next few days. Also, enjoy this example of the new custom mapmodes. Below is a map showing the trade income from food trade for all the provinces on the map.

Trade Income.jpg


One last treat, enjoy a map of burgher populations (Of course, the burgher distribution is not ideal at the moment. I will have to improve the factors that determine the burgher migration to get this to be a little better.)

Burgher Population.jpg
 
Last edited: