- #1

Addez123

- 199

- 21

- TL;DR Summary
- I have a table of items.

Each item has a

- demand, representing how many items has been sold

- desiredPrice: Given defaultDemand, the price should equal desiredPrice

There's a pot of gold that should be distributed among all items.

Items with high demand should receive LESS gold, and items with little demand should receive MORE gold.

The total gold in the pot equals the sum of all desiredPrice's among the items.

How do I calculate the price from demand?

How do I calculate defaultDemand?

This turned out to be more difficult than I thought!

Right now my calculations for the price for each item:

price = (1 - demand/totalDemand) * goldToDistribute

It doesn't work, example case:

goldToDistribute = 10

a.demand = 10

b.demand = 90

c.demand = 100

totalDemand = 200

a.price = (1 - 10/200)* 10 = 9.5

b.price = (1 - 90/200)* 10 = 5.5

already here we can see we've distributed 15gold when we only had 10 gold to distribute.

What would be a better function for price?

Basically what I'm looking for is a solution to

price = f(demand, totalDemand, goldToDistribute)

Right now my calculations for the price for each item:

price = (1 - demand/totalDemand) * goldToDistribute

It doesn't work, example case:

goldToDistribute = 10

a.demand = 10

b.demand = 90

c.demand = 100

totalDemand = 200

a.price = (1 - 10/200)* 10 = 9.5

b.price = (1 - 90/200)* 10 = 5.5

already here we can see we've distributed 15gold when we only had 10 gold to distribute.

What would be a better function for price?

Basically what I'm looking for is a solution to

price = f(demand, totalDemand, goldToDistribute)