Jump to content
  • Advertisement
Sign in to follow this  
psychictreason

Price of goods simulation for a shop

This topic is 4153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I've had a very good look around on this before asking this question as I just can't seem to find a suitable answer. Here is the problem: I want the player to be able to walk into a shop and sell a quantity of an item to the shop owner [computer]. This then changes the quantity of stock the store owner has [increasing it] thus the price of the item drops to compensate for the extra supply. If a player goes in and buys something and the shop owner hasn't received any more of it by the time he goes in next then the price should go up to compensate for the demand and hence lack of supply. Looking around I've seen loads of really complex ways of doing this by modelling artificial agents with different trading strategies etc to simulate a real market with movement of goods etc and this is massive overkill as I'm not building a market simulator. All I want though is the ability for the player to make some money if they cannily buy something from one place where supply is high and demand low and take it and sell to a place where demand is high and supply low. I can think of plenty of examples of doing this Elite being the classic one [though I think the prices there were fixed by tech level and a bit of judicious randomisation], as well as Freelancer, Star Flight, UrQuan Masters etc. There was also a nice simulation of this in all of the "Tycoon" games where if you bought or sold stock in another player the buy price would go up or down accordingly. As I say, I'm not after a complex market model just enough to inject a tiny bit of market forces into the simulation. If anyone has some general pointers I'd be extremely grateful as I've hit hair-pulling point on this now. Cheers AndrewF

Share this post


Link to post
Share on other sites
Advertisement
I use a variant of this:
price = (onhand / totalInWorld) * maximumPrice
That way, as the supply on hand approaches a monopoly, the price also approaches maximum.

Obviously you'd have to add some minimum price value to the system, as well as possibly capping to maximumPrice when it gets "near" to its minimum supply (e.g. for extremely rare items).

For calculating the player's sell price, you'd probably want to take this and then knock off a few bucks for margin.

The nice thing about this is that it's cleanly predictable, whereas in other more complicated systems you have a fair bit of randomness, which players hate when they're doing trading and such. If economics is not the primary focus of your game, keeping it constant is probably best. If you just want to pretend there are intelligent agents, use a random value to knock the price of an item up and down.

If you're worried about shopkeepers getting a monopoly and players not being able to buy back a unique quest-dependent object, then you could always rig up some system to redistribute the supply among other shopkeepers in the game world occasionally.

Share this post


Link to post
Share on other sites
I think this is a tricky problem to handle well. We have gone around and around trying to get decent market movement in Crown and Cutlass, but never really gotten anything we like.

Ravuya, does it really make sense to charge next to nothing if a shop-keeper has only 1 qty in his shop, but there are 100 total items in the world? Perhaps it does if the other 99 items are at the shop next door (I'm still not convinced), but what if they are on the other side of the world? In a world like Elite or Freelancer, the distance between shops shouldn't just be ignored. Even for trading within a single "town", does it really make sense that a shop with 10% of the inventory of another would be charging 1/10 of the price of the other?

What happens when you come into a town that owns 1/100 items (let's say a max price of 100, giving a price of $1), and you sell 5 items to the shop. Then the price suddenly goes to $6? That doesn't make sense to me. The supply goes up, so the price goes up? I don't think anyone would expect that to happen and it certainly goes against the basic rules of supply and demand.

Edit: Also, consider what happens with 0 qty. The shop keeper won't even give you money if you sell an item just because he happens to have none of it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mr Grinch
What happens when you come into a town that owns 1/100 items (let's say a max price of 100, giving a price of $1), and you sell 5 items to the shop. Then the price suddenly goes to $6? That doesn't make sense to me. The supply goes up, so the price goes up? I don't think anyone would expect that to happen and it certainly goes against the basic rules of supply and demand.


While the formula needs some work it does make sense in the supply & demand sense. The more of a particular item a shop has, the less supply there is for that item in the rest world. If a shop has 95% of the total quantity of an item, they can pretty much dictate the price since they are practically the only place to get it.

Share this post


Link to post
Share on other sites
tstrimp, the model doesn't make sense if you look at what psychictreason asked for. He wants to be able to buy low where there is lots of supply, and sell high where there is little supply. This equation has provided him with the opposite. If a player buys from a shop with little supply, it will cost very little. He will then go to a shop with lots of supply and sell for a large profit. It will tend towards monopoly, which won't make for much fun.

Share this post


Link to post
Share on other sites
Quote:
Original post by tstrimp
While the formula needs some work it does make sense in the supply & demand sense. The more of a particular item a shop has, the less supply there is for that item in the rest world. If a shop has 95% of the total quantity of an item, they can pretty much dictate the price since they are practically the only place to get it.
I don't think it does. There is no concept of demand in this model. It doesn't matter if you own 100% of a given commodity (I assume we are talking about commodities, not like semi-unique RPG items where the total number in existence is 3 or something) if there is no market for it. One idea we had in Crown and Cutlass was the assume a constant demand slope (the "elasticity of demand" if I remember my econ) for goods based on how "critical" they are. That is, a low supply of rum won't change it's price much since people won't buy it if the price goes too high. However, grain prices may go up much higher in a shortage because people need it to survive. I guess you could argue that pirates need rum to survive, but you get the idea...

As you can see, we always end up making it way too complicated. I think something along the lines of "at 0-10% of the total amount, calculate the price based on scarcity. At 85-100% of the total, calculate the price based on a monopoly. The rest of the time, do some random movements to keep it interesting" could work. Maybe that isn't enough. My problem with that is that you can't set up a "trade route" and consistently make money. Like I said, we could never get a good system worked out...

psychictreason, what are you looking for? Are you looking for some semi-believable market movement just to keep the game moving, or a more realistic supply-demand system where the player can focus on dependable "economics" that are at least consistent within your world?

Share this post


Link to post
Share on other sites
Quote:
Original post by Mr Grinch
I think something along the lines of "at 0-10% of the total amount, calculate the price based on scarcity. At 85-100% of the total, calculate the price based on a monopoly. The rest of the time, do some random movements to keep it interesting" could work. Maybe that isn't enough. My problem with that is that you can't set up a "trade route" and consistently make money. Like I said, we could never get a good system worked out...


I like this method.

Share this post


Link to post
Share on other sites
Quote:
Original post by tstrimp
While the formula needs some work it does make sense in the supply & demand sense. The more of a particular item a shop has, the less supply there is for that item in the rest world. If a shop has 95% of the total quantity of an item, they can pretty much dictate the price since they are practically the only place to get it.

If your talking about a price rising only a little then yes it does make sense.
Say a NPC only had 5 of the item.
He could charge say 20 coins for it, if someone sells him 20 of them he might charge 15 coins for it, if he has 95% of the quantity in the economy he might charge 25 coins or even 30 coins.

That would work in supply/demand.

Not:
NPC 5 items 20 coins
NPC 25 items 15 coins
NPC 95 items 100 coins

Share this post


Link to post
Share on other sites
Well what I would do if I were tasked with making such a system would be to:

A) Keep track of Unique/Rare items and use the stats of the item to determine the price.

B) If the item is not rare and it is produced then it would fall under regular supply and demand laws. If it is food you could factor in the current season (is that crop in season or not? has there been a drought recently? ect). If it is an imported good (you could keep track of this) from another land then it would cost more (perhaps just an import tax).

Then you could keep track of close shops and add some competition factors as well, based on which shop is making more money.

If we get a lot of an item then we focus on if we are the only shop with a lot of the item. If we are then we can charge heavily, otherwise we have to drop the price to move the product depending on the demand.

Then the only real factors that you have to vary from time to time is the distribution of the items in the shops and if it is single player then the demand for the items as well.

We could base the current level of "random" demand based on the season (obviously a glass of lemonade is more in demand in the summer then in the winter) and the occassion (If it is a special event then some items become higher in demand or during a major war close by there will be a higher demand for weapons).

Share this post


Link to post
Share on other sites
Hi Chaps,

I've had a quick skim of this getting up this morning and there are some great ideas in here without it going too complex which isn't the aim.

I'll have to have a proper read through a bit later after the chores are all done, however one thing that can be discounted is things like rare items.

Trade in this sense is much more along the old elite style of there being only commodities that can be traded. Some will be inherently cheaper than others due to their production cost - a piece of wood would be inherently cheaper than a chair by design as well as that wood will be more available than a chair.

Really what I'm looking for is a general simulation whereby the prices go up and down in a relatively predictable manner so the player can have some semi certainty they'll make a profit by taking goods like wood which is plentiful near a forest to a place like a desert where it isn't.

What I don't want though is a completely realistic market environment where full levels of supply and demand curves have to be modelled and then have artificial agents running in the background producing and buying goods in order to generate a market environment.

To give you more of an idea, this is a single player game for kids of about 11 years old and the bits of trading are only one part - the other main bit being one of exploration of the environment.

Cheers
AndrewF

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!