# Determining the price of a trade good depending on supply and demand of a marketplace

I've been meaning to add a market/trading system in my space-themed game where a player can buy from one station and sell it to another for profit, etc. (Examples would be Starsector, Elite: Dangerous, EVE Online)

The problem I've been having is actually determining the price of an item based on parameters like: Base Value, Supply, Demand, Transaction costs, Markup, and maybe others if I can think of them. I'm not particularly sure where to start with a price formula.

Any ideas on how to best decide on this?

• The formula depends on the feature and gameplay you would like to present to your players. You start by deciding what you think would be an interesting behaviour for the market, then figure what formula fits that behaviour, then test it and then review it and make adjustments. Commented Feb 27, 2021 at 18:17
• We get a variant of this question periodically. Have you searched through past Q&A on the topic for starting points? What would you like to do that's different from what's already been covered? Commented Feb 27, 2021 at 19:09
• I've read a couple of posts about this topic yeah, they've helped a bit, like this one. I think the problem I'm having at this moment though is not really knowing where to start to begin with. Like the actual formula for the price. I know its really vague, but I'm not really sure how to exactly explain it. Commented Feb 27, 2021 at 20:58
• I think the problem is that you've assumed there os just one correct formula that all games use, and so you're hoping someone will just tell you what it is. Gamedev doesn't usually work that way. the right formula for your game usually depends on the details of your game and the kinds of experiences you want to get from it. Try starting with something simple, like a base price times a multiplier that starts at 1 and scales up or down with demand. See how that feels. If it's not giving you a desired outcome, edit your question to articulate that outcome and ask for a strategy to achieve it. Commented Feb 27, 2021 at 21:06
• You don't need a formula. You can directly simulate the movements of supply and demand in relation to prices. Using a formula is more akin to using n(n-1)/2 to sum the first n integers. You can of course do this manually using a loop and some logic but no formula at all. Commented Apr 12, 2021 at 1:46

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 production or consumption 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 sell for very little, 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 need 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.