Opinion: Trade good price calculation needs improvement (1.8.0)

Users who are viewing this thread

azakhi

Sergeant Knight
M&BWBWF&S
Hello,
I have been reading game code to make a workshop mod for my own tastes and was curious why some trade good prices jump crazily. To give an example, while testing my mod I noticed that linen price would jump from 80 to 280 and back to 100 in just a couple seconds. So I checked how prices are calculated and it was really head scratching for me.

TLDR: Current price formula causes big price fluctuations for items that have high base value.

Here is the full formula:
Price Factor = (Demand / (0.1 * Supply + InStoreValue * 0.04 + 2)) ^ 0.6
First let me explain the terms here:
Price Factor: This is what the base value of the item will be multiplied with. For example if the price factor for Grain is calculated as 0.5 and base value is 10, the price will be 5.
Demand: This is calculated based on town prosperity and hardcoded demand per item. For example for Grain, it is 140 per 1000 prosperity (Ignoring luxury demand for simplicity). Note that this demand is for total value, not amount.
Supply: This is based on daily supply and supply history. Daily supply is based on InStoreValue, next term.
InStoreValue: This is total value of goods available in the town's market. For example if there are 10 grains and base value is 10, in store value for the day is 100.

This seems alright on paper but in practice there is an issue with items that has high base value. For example, lets consider Jewelry.
From game code and data, we have these values:
Demand per 1000 prosperity: 15
Base value: 600

Now lets calculate a hypothetical town with 3000 prosperity.
Demand: 60 (game code adds 1000 prosperity)
Price for amount of Jewelry available in the market:
1 Jewelry = 483
2 Jewelry = 321
3 Jewelry = 252
5 Jewelry = 186
10 Jewelry = 122

As you can see, the price jump is crazy and feels very unrealistic. You might say Jewelry is considered luxury and rare. Lets consider Linen, something workshops produce and sell to town market.
From game code and data, we have these values:
Demand per 1000 prosperity: 20
Base value: 200

Same town with 3000 prosperity.
Demand: 80
Price for amount of Linen available in the market:
1 Linen = 360
5 Linen = 141
10 Linen = 94
20 Linen = 62

This happens when difference between demand and base value of the item is too big.
This is a problem because if you have a Linen workshop, your profit depends hugely on random things like a caravan buying or selling Linen just before your workshop's profit is calculated. Even worse, your own workshop will be screwing itself by selling production right after each other. Since workshops do not care about current price and price fluctuations, your profit will be random and worse than it should be.
I made a mod for 1.7.2 that would make workshops wait for price to rise back up if it is abnormally low and then sell. The profit increased hugely without waiting for items to be sold for long. I will try to test same mod on 1.8.0 when I update it and will post comparison if I have time.

Hope TW will make changes regarding this.
 

Terco_Viejo

Spanish Gifquisition
Grandmaster Knight
giphy.gif

Here's something fishy... I'm missing a yellow banner here :iamamoron:.

---
I call upon @Blood Gryphon @Ananda_The_Destroyer for thorough analysis and feedback.
 
Last edited:
If I understand the solution in the right way=>So all workshops should produce only for the town where they are staying in and only than when it is the most profitable?

I will tell it the caravan masters, that they will lose their jobs.
 

azakhi

Sergeant Knight
M&BWBWF&S
If I understand the solution in the right way=>So all workshops should produce only for the town where they are staying in and only than when it is the most profitable?

I will tell it the caravan masters, that they will lose their jobs.
Not really. The issue you mention stems from whole game being balanced around this crazy price jumps. Even as a player, I don't usually think of logical reasons what to buy or sell. It is always checking if something is good to buy or sell just looking at price. If the price jumps were fixed, that doesn't mean all the cities would be around same price. It means price would be more stable. That doesn't hurt caravan trade since they can still buy from where it is low and sell where it is high. And the game would be balanced for that.
 

mikeboix

Master Knight
WBNWWF&SM&BVC
Hello,
I have been reading game code to make a workshop mod for my own tastes and was curious why some trade good prices jump crazily. To give an example, while testing my mod I noticed that linen price would jump from 80 to 280 and back to 100 in just a couple seconds. So I checked how prices are calculated and it was really head scratching for me.

TLDR: Current price formula causes big price fluctuations for items that have high base value.

Here is the full formula:

First let me explain the terms here:
Price Factor: This is what the base value of the item will be multiplied with. For example if the price factor for Grain is calculated as 0.5 and base value is 10, the price will be 5.
Demand: This is calculated based on town prosperity and hardcoded demand per item. For example for Grain, it is 140 per 1000 prosperity (Ignoring luxury demand for simplicity). Note that this demand is for total value, not amount.
Supply: This is based on daily supply and supply history. Daily supply is based on InStoreValue, next term.
InStoreValue: This is total value of goods available in the town's market. For example if there are 10 grains and base value is 10, in store value for the day is 100.

This seems alright on paper but in practice there is an issue with items that has high base value. For example, lets consider Jewelry.
From game code and data, we have these values:
Demand per 1000 prosperity: 15
Base value: 600

Now lets calculate a hypothetical town with 3000 prosperity.
Demand: 60 (game code adds 1000 prosperity)
Price for amount of Jewelry available in the market:
1 Jewelry = 483
2 Jewelry = 321
3 Jewelry = 252
5 Jewelry = 186
10 Jewelry = 122

As you can see, the price jump is crazy and feels very unrealistic. You might say Jewelry is considered luxury and rare. Lets consider Linen, something workshops produce and sell to town market.
From game code and data, we have these values:
Demand per 1000 prosperity: 20
Base value: 200

Same town with 3000 prosperity.
Demand: 80
Price for amount of Linen available in the market:
1 Linen = 360
5 Linen = 141
10 Linen = 94
20 Linen = 62

This happens when difference between demand and base value of the item is too big.
This is a problem because if you have a Linen workshop, your profit depends hugely on random things like a caravan buying or selling Linen just before your workshop's profit is calculated. Even worse, your own workshop will be screwing itself by selling production right after each other. Since workshops do not care about current price and price fluctuations, your profit will be random and worse than it should be.
I made a mod for 1.7.2 that would make workshops wait for price to rise back up if it is abnormally low and then sell. The profit increased hugely without waiting for items to be sold for long. I will try to test same mod on 1.8.0 when I update it and will post comparison if I have time.

Hope TW will make changes regarding this.
Weren't you a TW developer until not long ago? What happened, are they cutting in the development budget?
 
Hello,
I have been reading game code to make a workshop mod for my own tastes and was curious why some trade good prices jump crazily. To give an example, while testing my mod I noticed that linen price would jump from 80 to 280 and back to 100 in just a couple seconds. So I checked how prices are calculated and it was really head scratching for me.

TLDR: Current price formula causes big price fluctuations for items that have high base value.

Here is the full formula:

First let me explain the terms here:
Price Factor: This is what the base value of the item will be multiplied with. For example if the price factor for Grain is calculated as 0.5 and base value is 10, the price will be 5.
Demand: This is calculated based on town prosperity and hardcoded demand per item. For example for Grain, it is 140 per 1000 prosperity (Ignoring luxury demand for simplicity). Note that this demand is for total value, not amount.
Supply: This is based on daily supply and supply history. Daily supply is based on InStoreValue, next term.
InStoreValue: This is total value of goods available in the town's market. For example if there are 10 grains and base value is 10, in store value for the day is 100.

This seems alright on paper but in practice there is an issue with items that has high base value. For example, lets consider Jewelry.
From game code and data, we have these values:
Demand per 1000 prosperity: 15
Base value: 600

Now lets calculate a hypothetical town with 3000 prosperity.
Demand: 60 (game code adds 1000 prosperity)
Price for amount of Jewelry available in the market:
1 Jewelry = 483
2 Jewelry = 321
3 Jewelry = 252
5 Jewelry = 186
10 Jewelry = 122

As you can see, the price jump is crazy and feels very unrealistic. You might say Jewelry is considered luxury and rare. Lets consider Linen, something workshops produce and sell to town market.
From game code and data, we have these values:
Demand per 1000 prosperity: 20
Base value: 200

Same town with 3000 prosperity.
Demand: 80
Price for amount of Linen available in the market:
1 Linen = 360
5 Linen = 141
10 Linen = 94
20 Linen = 62

This happens when difference between demand and base value of the item is too big.
This is a problem because if you have a Linen workshop, your profit depends hugely on random things like a caravan buying or selling Linen just before your workshop's profit is calculated. Even worse, your own workshop will be screwing itself by selling production right after each other. Since workshops do not care about current price and price fluctuations, your profit will be random and worse than it should be.
I made a mod for 1.7.2 that would make workshops wait for price to rise back up if it is abnormally low and then sell. The profit increased hugely without waiting for items to be sold for long. I will try to test same mod on 1.8.0 when I update it and will post comparison if I have time.

Hope TW will make changes regarding this.
Would it be possible to let the Worksop sell/give the items to a caravan that you own, so the clan can get good prices elsewhere. This would combine both investments together?
 

azakhi

Sergeant Knight
M&BWBWF&S
Would it be possible to let the Worksop sell/give the items to a caravan that you own, so the clan can get good prices elsewhere. This would combine both investments together?
I actually was thinking of adding this later. Should be possible.
 

svelok

Sergeant
Here is the full formula:
In some calculation somewhere (some other part of economic code, forget where offhand) the game uses a weighted demand/supply value, that's something like 85% of yesterday's demand plus 15% of today's demand. Seems like you could probably do that kind of weighting in the buy/sell price formula too, and achieve a less swingy price - longer term demand mattering more than instantaneous demand.

Might make vanilla caravans weird, since they have magic price radar, so you would also need to do something to stop cities from overbuying or overselling to caravans. Actually that might be the crux of the whole problem, low volume (1-5 units) is hard to price correctly.
 

azakhi

Sergeant Knight
M&BWBWF&S
In some calculation somewhere (some other part of economic code, forget where offhand) the game uses a weighted demand/supply value, that's something like 85% of yesterday's demand plus 15% of today's demand. Seems like you could probably do that kind of weighting in the buy/sell price formula too, and achieve a less swingy price - longer term demand mattering more than instantaneous demand.

Might make vanilla caravans weird, since they have magic price radar, so you would also need to do something to stop cities from overbuying or overselling to caravans. Actually that might be the crux of the whole problem, low volume (1-5 units) is hard to price correctly.
Yes I am aware of this. I didn't go into detail for simplicity's sake. I agree it might affect current caravans but I think that is because caravans are balanced around this seemingly random price changes. Game code caps minimum and maximum prices at 0.1 and 10 times of the base value in order. This means in theory you can see 100 times price difference between 2 cities. Although in practice it is not the case, you can still see one city buying something another city selling 5 times the price. So whole trade is basically built around catching this momentary "good deal"s. Even caravans do this.
For me it doesn't feel like a good gameplay, feels random and unrealistic. Jewelry's price shouldn't drop to 1/3 by the time you sell 5th, in real world any sane trader would know they can sell it to a caravan or something soon after cause history shows Jewelry is selling for much higher.
And regarding caravans suffering from this, I think they would in a way benefit from it too. The reason a caravan can't pick up 50 grapes from left side and sell on the right side is because 50 is a big number and average selling price will drop a lot.
Just as an example consider Linen example above. Suppose a caravan wants to buy Linen from a town that has 20 Linens and sell to a town that doesn't have any. Now in an ideal world it should buy and carry about 10, stabilizing economy. 10 Linen from first town would cost roughly 80 a piece and would sell at roughly 120 a piece in second town. That is 40 gold profit a piece, pretty good number. However this is very risky. By the time you make it to second town, if someone else sold only 5 Linens, your average will drop to roughly 90 golds and will make you only 10 gold a piece profit. So it is better for caravan to buy only 5 Linens if not less. That would make caravan roughly 600 gold profit if nobody else sells before it does. But it is very likely someone else will sell some. Now suppose towns have magical memory so they can remember the history of Linen prices. First town would know that it will end up with more than needed Linens again, so it wouldn't be too greedy while selling. Second town would know without caravans it wouldn't have enough Linens so it wouldn't be too stingy while buying. In this scenario a caravan can do smaller profit margin trades but in bigger amounts, ending up pretty much same if not better than how the game currently is.
And again, caravans are currently balanced around big price differences, if that would be fixed, they can be rebalanced for better prices.
There is also the fact that AI running caravans and workshops without making much profit and only making it less profitable for everybody including player.
 

Errayn

Sergeant Knight at Arms
Inappropriate behavior (off-topic targeting ex-employees)
I don't get your point I am afraid.
I don't get your point with this thread too. As someone who has been worked in Taleworlds as a developer (and comes from mp dev ahahah). The situation you describe is not something new.

It's funny to come and give advice on the sp side with trade calculations in this forum. while the job you guys have done in the multiplayer side of bannerlord is in the middle. I wish you would have played a little mp too while working in the taleworlds.

tldr, Please don't make back seating to Taleworlds as old multiplayer dev.

Gerisine türkce devam edecegim,
Eski MP devi bile SPyi acip iki saat oynayinca bu durumun bok gibi oldugunu cozmesi normal zaten. Oyunun bir cok yerinde oldugu gibi.
I started playing rather recently and haven't been following forums to say much about overall situation of economy but this one bothers me

lakin benim buradan anladigim su,

"O kadar yazmissiniz da biz bakmiyorduk foruma falan zaten calisiyorken, Sirkette oyunu oynayan da yok zaten, sirketten ayrildiktan sonra bi oynayayim dedim, les gibi olmus ben duzelteyim kodu dedim"

bunu acikca forumda dile getirip, konu acip bide mod yapmak tamamen komik.
TWnin icini gormus birisi olarak forumda I Hope TW, demen ise de ironik hatta trajikomik.
 

Helerek

Recruit
Maybe try moving supply out of the parenthesis. It shouldn't have this big factor on a price.
Adding another 0 to 0.01 or 0.02 to Supply should also reduce it's impact.
Another thing you might add is demand * workshop production. This would ignore the goods the workshop produces and keep the price on the same level (until the workshop stops producing?, which might be bad for a price)
Addind some average variable of goods sold to caravans and removing them from supply should stabilize the price. Not sure how hard it is to code tho.
 

MostBlunted

Sergeant Knight at Arms
Pretty much sums up bannerlord development for me.
TBF, would you have played early as a dev when you´re aware that it is just an alpha you released with 90% placeholders and 10% bugs?

I´m also not really surprised that the devs don´t play a lot, that explains most issues. I guess they´re sitting in meetings talking about how theoretically stuff should work but not noticing that the stuff doesn´t ****ing work.
 

azakhi

Sergeant Knight
M&BWBWF&S
Maybe try moving supply out of the parenthesis. It shouldn't have this big factor on a price.
Adding another 0 to 0.01 or 0.02 to Supply should also reduce it's impact.
Another thing you might add is demand * workshop production. This would ignore the goods the workshop produces and keep the price on the same level (until the workshop stops producing?, which might be bad for a price)
Addind some average variable of goods sold to caravans and removing them from supply should stabilize the price. Not sure how hard it is to code tho.
Maybe, I haven't tried different methods myself since it might affect overall economy a lot and I don't want to be modding lots of different areas when the economy is getting updates. I should also note though this is an issue only for items that have very low demand relative to their base value. For example Jewelry has 600 base value but demand is around 60-90 so towns consume only 0.1-0.15 Jewelry. Which causes big swings because even a couple Jewelry is 10-20 times the demand.
 
Top Bottom