# How to code a one-sided virtual economy

I'm attempting to make an online game with a mini-economy in it. The challenge is that the only person selling anything will be the website itself, and hence the supply and demand curve doesn't apply (as it costs the website nothing to produce the items being sold).

Products sold will have several factors that contribute to its value. Each of these factors can be represented by a number, but it is difficult to know if product `X` is better than product `Y` if `X` has a better `A` and `Y` has a better `B`. The monetary value of each factor (and thus, each product) is hard for me to calculate, which is why I would like an economy to do that for me.

Some products are upper-end products, and should be inaccessible to players who don't have the money.

There will be several types of products on the market, each serving completely different purposes in the game.

I'm guessing that there will be a larger number of lower-level players.

I have three ideas on how to develop it:

1. Generate an initial price on each product. Each time a person buys a product `A`, the price of `A` goes up a fixed amount, `X`, and the price of every other product goes down `X/(# of products)`.
2. Generate an initial price on each product. Each time a person buys a product `A`, the price goes up `X`. Each minute, the price of `A` goes down `Y`.
3. Produce each product at a fixed rate, with lower amounts of high-end products. Upon production, add the product to an auction, where each player can cast a bid on the amount he will pay. The initial bid will be generated.

I believe that method #1 and #2 will overvalue low end products, and undervalue high end products, so #3 is my favorite. #3 also only has 1 value for me to generate, while #1 and #2 have multiple. However, #3 may have problems if the initial bid is too high for the products, or it produces products at a lower rate than it should, causing a shortage.

Is auctioning off products the best way to determine the product's price? Is there a better way to do this?

• Very often, the answer to questions like this is "use your best judgment." Commented Dec 20, 2014 at 17:32
• This is more of an economics question than a programming or algorithms question. That's probably why you're getting so little feedback. Commented Dec 20, 2014 at 17:33
• You could try WorldBuilding.Stackexchange.com. They talk about things like this all the time. But check their Help Center/On-Topic article first. Commented Dec 20, 2014 at 17:34

Virtual economies can be very hard to get right. Fortunately, by not having players selling items they've crafted/looted themselves you've simplified the problem somewhat: you can control supply, which will allow you to prevent the massive deflation in item values that can occur when they're produced in much higher volumes than they're consumed.

A couple of other problems to watch out for:

1. Can players transfer items between themselves? If so, this will reduce demand for low level items substantially, as players trade away items they no longer need.

2. (assuming you're talking about selling items for game currency, not real money) what prevents high level players from accumulating extremely large amounts of cash, which might cause runaway inflation?

Assuming you have good answers to these (item decay, where items quality is reduced with use, is one possible answer to both problems, but a lot of players don't like it), auctions are a good bet. You can generate the initial bids as a percentage of recent selling prices for similar items, which should solve that problem. And then keep an eye out for products which often don't sell, or which always attract a lot of bids, as these could be warnings that you've got the resupply rate wrong.

Here are a few must-read articles on online game economies:

Without knowing much about the intended game; I'd give each attribute a weighting factor such that the price is the sum of each "attribute * weighting factor".

For example, let's say (for weapons) you have the 4 attributes durability, slice damage, bash damage and speed. You might decide to assign weights like this:

• 3 coins per point of durability
• 10 coins per point of slice damage
• 8 coins per point of bash damage
• 5 coins per point of speed

Now imagine there's a sword with 120 durability that does 20 slice damage per hit, and can hit 1 time per second. It's price would be 120*3+20*10+5*1 = 565 coins. The price of a mace with 160 durability and 19 bash damage that can hit 0.8 times per second would be 3*160+19*8+5*0.8 = 636 coins.

The nice things about a system like this is that you can fine-tune the weights (and effect whole groups of items at once); and that it's easy to dynamically generate random items that are priced appropriately.

Note: One of the things I dislike about a lot of games is that there's a specific set of equipment to achieve the best result; and you can find out all the stats for all the pieces of equipment on a web site. E.g. a typical "min/max" player might decide their equipment (from the item list on a fan's web site) then grind a specific quest or dungeon until they get that piece of equipment. The random/dynamically generated equipment solves that (forces players to play the game continually hoping they'll get a lucky drop).

Shortage is not an issue. Economy works the way it is exactly because there is shortage. Without shortage, you cannot have an economy. If there is shortage of a highly desired item because its production rate is too low, people will bid up, raising the price, making the highly desirable item inaccessible to less wealthy players. At that point, you can increase or reduce production rate to increase your profit/revenue; at one point, the price will decrease to the point where increasing production rate further will no longer increase your profit/revenue. Congratulations, you've reached the market equilibrium. That's the right price that people are willing to pay for that item. Note that as you don't actually have production costs, profit is the same as revenue.

Optionally, you can model the production cost to shape the market the way you wanted it to be. Your shops can have a total production capacity that is shared among all items so that increasing the production rate of one item reduces the production rate of all other items. A higher level item should have a higher production cost and the production cost of a single type of item should increase as production rate of that item type increases. If people keeps bidding a highly desirable item price up, that would increase its production rate up to the point where increasing the production rate of that item any further actually reduces the shop's total "profit". The goal of the algorithm that controls production rate should be to maximize profit given a certain production capacity.

These would be your controls over the market:

1. Total production capacity (controls global item price)
2. Production multipliers of each item (controls the price of that item type)

The market capacity formulas would be something like:

``````Constraint:
SUM[(Production Rate of I * Production Multiplier of I) for I in (All Items)] <= Total capacity
Sales Rate of I < Production Rate of I
``````

And you have to solve:

``````Goal: Maximize(Sum[(Sales Rate of I * Selling Price of I) for I in (All Items)] by varying Production Rate
``````

As more people bids on a highly desirable item, the price of that item will go up making it unaffordable for most people and the majority would settle for the more affordable items. The shops, in its pursuit of maximizing profit, will make more of the affordable items to match their demands.

By setting the goal of shops as maximizing profit, the market also acts as a dynamic money sink. If there's a lot of rich players, the price of the most desired items would be driven way, way up, in effect the bids increases the money sink rate and self-regulating inflation.