Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document price mechanics #288

Open
wvpm opened this issue Nov 17, 2024 · 1 comment
Open

Document price mechanics #288

wvpm opened this issue Nov 17, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@wvpm
Copy link
Contributor

wvpm commented Nov 17, 2024

Problem

In Victoria 2 each good has a price. These prices change depending on supply, demand and a base price. The base price is defined in common/goods.txt.

According to the wiki prices increase when demand > supply and decrease when demand < supply. It states that prices change with £ 0.01 per day. It also states that the minimum price is 0.22x the base price and the maximum is 5x the base price.

According to Reddit under "The prices of goods", price changes towards base price * square root(demand / supply).

I also did my own testing and confirmed prices changes by £ 0.01 per day.
In a test where there is a good with base price 1, I repeatedly sold 30000 units per day on the market (using cheats).
The price dropped to 0.58. The market screen claimed a supply of 32275.021and a demand of 8353.598. See Discord.

The price would not drop below 0.58. The square root(demand/supply) would be 0.5087.
So the price does not even hit the square root as claimed by Reddit.

OpenVic needs to faithfully recreate this behaviour. The exact mechanic remains hidden and need to be discovered and documented.

Solution

Run Victoria 2 and record prices with the demand, supply and base price.
Feel free to use cheats or mods to push prices to their extremes.

Work out the mechanics of price changes using the recorded data.

Document your findings in OpenVic/docs/simulation/calculations.yaml.

For questions, just ask me on Discord.

@wvpm wvpm added documentation Improvements or additions to documentation good first issue Good for newcomers labels Nov 17, 2024
@wvpm
Copy link
Contributor Author

wvpm commented Nov 17, 2024

I confirm that 5x base price is the absolute maximum price.
This was tested by setting oil base price to 0.5, setting Sikkim's RGO to oil and buying 2000 oil.
The price would rise by 0.01 until it reached 2.5.

The absolute minimum could be 0.22x base price. In my test, the lowest price I could get (by selling 500 oil daily) is 0.118.
This is 0.236x base price. I suspect the price didn't go lower as decreasing it by 0.01 would result in 0.108, which is below 0.22x base price.

In repeated the selling test with a new game and the price would not drop below 0.12. So the minimum might be 0.24x or the code prevents it from hitting 0.11 (perhaps due to rounding errors).

My results: https://docs.google.com/spreadsheets/d/e/2PACX-1vTLGaVZjGaovjJXEcLL1eltfKmDH6EzIqGi5qKVJyvnTsY9dG9dCzvMh_p5OuDEfkhXBk4HoJMNIRJ5/pubhtml?gid=0&amp;single=true&amp;widget=true&amp;headers=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant