First, I'm not absolutely certain if this site is the correct one for this question as it covers multiple topics simultaneously.

Second, Some context to my question, I'm working on an in-game economy for a single-player video game, and want the players actions (specifically buying and selling of items) to affect and hopefully be affected by the 'world's economic state', for example A blacksmith needs 100 units of iron, but only 25 units are in circulation therefore the cost to buy iron increases, while adding and removing items from the games economy is simple, calculating the cost an Item should have is not quite so simple, for the time being I'm using a simple algorithm where if there is no supply the 'multiplier' for cost would be equal to the demand, which for a needed item with no supply could reach astronomical prices and if there is supply the calculation is demand / supply which with low numbers eg demand: 2, supply: 1 seems an unreasonable increase in price.

The actual question is somewhat two-fold, a) Can an economic state be boiled down to a mathematical equation like this; and b) If so, how would I at least approximate an economy like this?


To clarify the example I gave, the blacksmith is requesting 100 units, but the region/village only has 25 units available in storage.

  • $\begingroup$ If only 25 units of iron are in circulation how will the blacksmith get 100 of them? $\endgroup$ Commented Jan 7, 2023 at 3:40
  • $\begingroup$ @user253751 via the player or other NPC (if I add any mining NPC's to the game) adding more iron into circulation, more specifically by mining and selling ores. $\endgroup$
    – RWolfe
    Commented Jan 7, 2023 at 4:45
  • $\begingroup$ How desperate to get iron is the blacksmith? $\endgroup$ Commented Jan 7, 2023 at 4:48
  • $\begingroup$ That would depend on the priority assigned to the 'project' the blacksmith is trying to complete $\endgroup$
    – RWolfe
    Commented Jan 7, 2023 at 4:51
  • 1
    $\begingroup$ This may help: econstor.eu/bitstream/10419/268397/1/fiatmoneyvalue.pdf - it discusses an agent based model in which prices are continuously adjusted. In particular look at section 2 where it describes a "Sellers’ pricing policy" and "Purchasers’ propensity to spend". $\endgroup$
    – Mick
    Commented Jun 6, 2023 at 14:33

1 Answer 1


a) Can an economic state be boiled down to a mathematical equation like this

Economic states can be boiled down to equations, but not equations like $price=demand/supply$ that makes little sense. Of course, in a game development you can model your economy in whatever way you want but if you want it to have at least some economic rationale behind it that would not work.

At a very minimum you should at least model simple linear demand and supply for every market where you want to determine prices. You can also increase the complexity by interconnecting them but I am not game developer and I have no idea if that would be feasible to program it in your game (although when I was younger I used to play video games and modded version of Victoria II from paradox had quite decent realistic economic system, so it is possible to do it within some games at least. But I do not remember which mods was I using - some mods that claimed to improve realism of the economy, you might want to check that out, although its not necessary best simulation of medieval economy as it was set in Victorian era).

b) If so, how would I at least approximate an economy like this?

At a minimum you should model some reasonable supply and demand. If villagers have only 25 units of iron and it is an endowment (villagers do not produce iron just happen to have one) and there are no alternative suppliers then supply will be:


Next when it comes to demand the smith might want to have 100 pieces of iron, but not at any price. It is not realistic to think that he would demand 100 pieces at some exorbitant prices.

If you want to take short cut you can simply model it as some downward sloping linear function. For example, the demand of smith could be given by:


Then to find a price you just equate supply and demand:

$$25=200-2p \implies p=87.5$$

If you want to make it more realistic you can model smith as a producer where demand will depend on how much profitably he can sell products from iron. You would have some smith's profit function:

$$\Pi = p(q(i))q(i) - c(q(i))$$

where $q$ would be quantity of ploughs or swords or whatever produced. The production of $q$ would depend on iron for example $q= \sqrt(i)$, $p(q)$ would be the inverse demand function of knights/villagers that buy the $q$ swords/ploughs from the blacksmith. It could be for example, $p= 100-q$ you can make up some other numbers you consider reasonable. Then the cost function $c(q)$ would tell you how much it costed to produce the sword/plough which in this case would the cost of iron (assuming for simplicity no labor costs which could be added but it would make the problem more complex as we would have to then model separate labor market). You will want to leave the cost as some $c$ because you want to find not just quantity of iron demanded at some specific price but at any price. Then you can simply solve it for the $i^*$ using calculus in terms of $c$ and it will give you the demand function of the smith $i(c)$. Then this demand function can be equated to supply to find out what the price of iron c would be.

You can add infinite amount of complexity on top of it depending on how realistic you want to get.

  • $\begingroup$ After the conversation in the comments of my actual question I had come up with an idea for each item to be given a value as a range as opposed to a base price, and to provide a shopkeep of any type with a list of items they keep and the range they would like to keep stock of each item, and for any given item get the percent between their min and max stock count that the actual count is, and use that to interpolate between the range of prices for that item. $\endgroup$
    – RWolfe
    Commented Jan 7, 2023 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.