Search code examples
language-agnosticmudeconomics

Simple formula for adjusting price based on supply & demand


I'm designing a rpg/mud game with merchant NPCs and I want their prices to adjust dynamically based on supply & demand.

What I have already figured out:

  • I don't need a complex, "realistic" system but just a simple multiplier based on some statistical data
  • I want the algorithm to be resistant to abuse and low size of player population, so the multiplier propably should not be dynamically generated, but rather stored with other merchant data and updated once per a few days
  • And thus the required statistical data should be low in volume - there will be many NPCs, each with its own item list, prices and statistics - so it can rapidly grow in size with development of game world.

The problem is: What type of formula would be the "best" for this kind of multiplier?

Disclaimers:

  • This may seem related to Supply Demand Modeling but I dont' need a library, just some tips on how to do it myself.
  • I am aware there may already be an economics model simulating this problem, but I never studied economics so I don't even know what I should look for.
  • No, this is not a homework, but it propably sounds like one so I'm adding the tag :P

Solution

  • I'm a game developer who has studied economics, so I can give you the economists two hands answer.

    On the one hand you have economics where the formula is remarkably simple. Just look it up on google or browse chapter 1 of any econ book. You could use this formula, but since economics is about personal behavior, it ignores the complexities of human decision making and just calls it maximizing(enter whatever is being maximized here). This means that in order to use a really simple formula you must implement really complex AI unless the players are going to be the only producer/consumer. Unless you are building a simulation, this is not a good way to go.

    On the other hand, you really care about fun. So no formula anywhere close real is perfectly fine. Use a linear distribution so it becomes a line function and your variables to play with are slope and Y. Use a curve function and you add an exponential to play with. Put these in a data file and play with them till it's fun. Trust me if you get fun then very few people will notice it's not right.

    Start by assuming a base cost for the item. This should be no unusual supply or demand. Determine a reasonable inventory. This inventory does not need to be the amount available at one shop, but available in general. Next determine the max anyone would pay for the only one of these. Again this is just to make it fun. take available on the x axis and cost on the Y and compute the slope.

    A sword is pretty widely available so lets say that at any given time you can get 10 at 5 gold. Now lets say that nobody would ever pay more than 20 if there is only 1. You have two point 10, 5 and 1, 20. when the line crosses y=0, merchants will no longer buy a sword.

    Linear "curves" are pretty common in economics. most curves like the famous Laffer Curve when plotted are really almost flat.