22 February 2013

NPC Pricing - Combining and Designing Functions

   In this part of NPC Pricing series, I'll examine how to combine price altering functions. A price function with several variables can be used to better adjust player's buying behaviors or achieve specific design purposes.


If you haven't read the previous articles in NPC Pricing series, give them a try:

-
---
-----
Combining Functions:
   To combine a function all you need to do is their respective factors together in the same Price Algorithm. For example look at this combination of Buying Behavior (increase price factor) and a Time function (price decrease factor):
Price = (Starting value) *(Buy Function) * (Time function)
  • (Buy Function) = (Buying Factor)^(number of units)
  • (Time function) = (Time factor)^(number of days)
Example:
  • Starting Price  1500 gold pieces
  • Buying behavior factor = 1,10 (+10% per buy)
  • Sold units = 25
  • Time factor = 0,98 (-2% per day)
  • Days passed = 60
Price = 1500 * (1,05^25) * (0,98^60) = 1500 * 10,83 * 0,30  = 4876
   So in this scenario price would have increased 3,3 times, probably because the initial price was considered low. In others words players will spend their Gold on any desired good as long as they think it’s not more advantageous spending it elsewhere. However, if gold earning is too low when compared to how much gold is required, player might give up on farming gold.

Combining Individual and Collective Functions:
   Sometimes developers introduce a new shop with goods and services they don’t want the more rich players to acquire right away in large quantities. A workaround is putting a buying behavior factor for both Personal and Collective Behaviors in the same algorithm. Taking the earlier example with modifications:

Price = (Starting value) *(Personal Buy Function) * (Colective Buy Function) * (Time function)
  • (Personal Buy Function) = (Buying Factor 1)^(number of units that player bought)
  • (Collective Buy Function) = (Buying Factor 2)^(number of units all player bought)
  • (Time function) = (Time factor)^(number of days)
Example:
  • Starting Price: 1500 gold pieces
  • Buying behavior factor 1 (individual) = 1,75 (+75% per buy)
  • Personally sold units = 2
  • Buying behavior factor 2 (collective) = 1,05 (+5% per buy)
  • Collective sold units = 50
  • Time factor = 0,95 (-5% per day)
  • Days passed = 60
Price = 1500 * (1,75^2) * (1,05^50) * (0,98^60)
Price = 1500 * 3,06 * 11,47*  0,04
Price = 2105

  Now if the player hadn’t bought any good he would pay:

Price = 1500 * 11,47*  0,04  = 688

  We can see a massive difference in price in this scenario. This kind of function is very useful because it will charge more gold if player are acquiring more good than they are supposed to. There are better ways to adjust this kind of algorithm as we will see next.

Establishing a function for Desired Selling Rate
   Well sometimes designers want to estabilish a selling rate of a given good. Let’s say you want to sell 3 of a given item per day. In that case, how should price variate?
  • Price would need to go up if more than 3 goods are sold in a day
  • Price would need to go down if less than 3 goods are sold
  • Price should stay stable if 3 goods are sold in a day.

  So in this case we make ab algorithm like:


Price = (Initial Price)* f(Selling rate)

  So in order to make a function for Selling Rate you can:


Factor ^( Actual Selling Rate – Desired Selling Rate)
  • Factor = Can be understood as how fast you want prices to variate (must be a number higher than 1)
  • Actual Selling Rate = How many units where sold in the relevant time interval
  • Desired Selling Rate = How many units you sold in the relevant time interval
   I mentioned Relevant Time interval because this value depends on how often you need to update the price. If you want to sell 3 units per day, and only 8 hours have passed, the Desired Sells Rate would be 1 for this time interval.

Fine-tuning a Function with another Function
   Let’s say you want players to buy a good for every 6 hours of their personal game-play. Well we adjust price with these two variables in mind. The design process should go like this:
  • Decision 1 - Price will increase with each personal buy
  • Decision 2 - Price will decrease with personal playing time
  • Decision 3 - Both functions cancel each one out with 6 hours and 1 good bought
Price = (starting Price) * (Buy function) * (Time function)

   So to find the factors for these function we would have to solve:

Buy factor^(1) *  Time factor^(6) = 1

   Since we want to make prohibitive to buy several good in a row, we can set Buy Factor to 2, in which case We would need a Time Factor of 1,122.

   Keep in mind time count (time factor exponent) is negative in this case (so time factor divides the price).

Finding Market price
   Check Wikipedia for a relevant article on this subject. Market price can be understood as an equilibrium price where a good is neither too expansive nor too cheap.
   This is a frequent problem designers have when they introduce new NPC Shops. They don’t know which starting price is most adequate and while they can adjust prices quickly upwards with buying functions, sometimes prices can end up too high take a very long while to decrease. To solve this problem we can put a function altering factors inside an algorithm.
   This accelerated variation in the factors helps to reach an adequate price quicker. If players buy too frequently (because initial price is too low) prices will increase much quicker and higher. Otherwise, if players buy too slowly (because initial price is too high), prices will decrease quicker. Since I'm considering a function with buying behavior as price increasing factor and time passing as a price decreasing factor we need to use a variable suitable to affect both of them for Function X. As pointed earlier Selling Rate in a good way to combine Buying Behavior and Time in the same variable. In fact let's draw a similar but modified function to the one pointed in the earlier section:


(Factor Variation) * |(Actual Selling Rate - Desired Selling Rate)|


  • Variation - How quick is each factor changed when selling at an undesired selling rate
    •  Must be higher than 1
      • This value can be based on number of players needing the Good
      • It's very important to consider how quickly will prices drop when actual selling rate is zero
  • |(x)| - Absolute value of the difference between Actual and Desired Selling rates
    • Actual Selling Rate - How many units were sold
    • Desired Selling Rate - Seemingly arbitrary value
    • This value can be based on number of players needing the Good