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: 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.
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 = (Demand / (0.1 * Supply + InStoreValue * 0.04 + 2)) ^ 0.6
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.