The approach I am using in my current prototype for a space economy simulation is quite simple.
Each market keeps track of how much it has of each resource over time. When the amount of a resource increases over the past x minutes, lower the price. When the amount decreases, increase the price. That way each trading post will reach an equilibrium price where supply and demand will be equal and the stock will stay constant.
This, of course, relies on two features you need in your game:
- It relies on trading. You need lots of agents in the game world who try to make a profit through trading between markets. These can be either human players or AI actors.
- It relies on production output and consumption input adjusting to price developments. When production and consumption never change, then all prices will over time either go to the minimum or the maximum, depending on whether overall supply or demand is larger across the whole game world. So you need a dynamic economy system where the actors adjust their productivity depending on the profitability of their business. When the price for raw materials is low and the price for products is high, then that industry has to grow. When the raw materials are expensive and the products are cheap, that industry has to shrink. This can either be done by allowing agents to build (and destroy) production facilities or by having any automatic resource siphons or resource drains in the game adjust their output over time to the current prices.
This system will over time reach an equilibrium where supply and demand match exactly and where all prices are constant. Now this is of course a rather boring world to play in. So in order to create interesting business opportunities for the players, you need to shake things up occasionally. There needs to be some events which happen occasionally and:
- Destroy production capabilities or resources.
- Create a sudden influx of cheap raw materials.
- Create a sudden demand for products.
- Interrupt supply lines.
All of these will open up new business opportunities for the players to slip into.