InnominateOne

Matter of Scale Balance Patch

Oct 22nd, 2015
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. goalBuildingBloodhoundCount = 90;
  2. exponentialIgnoreBuildings = 40;
  3. levelTimeExponent = 1.15;
  4.  
  5. goalBuildingEquivalence =
  6.     function(level, bid)
  7.     {
  8.         //we want every combination to take approximately as long as n bloodhounds + 15% longer (cumulative) per level
  9.         //i.e. level 0 is T(n bh)*1.15^0, level 1 is T(n bh)*1.15^1, level 2 is T(n bh)*1.15^2, etc.
  10.         //note that this is an idealised calculation, not factoring in real concerns like tick rate, lost money (if any), etc.
  11.         var timeBloodhounds = goalBuildingTime(0, 0, goalBuildingBloodhoundCount);
  12.         var timeLevel = timeBloodhounds*Math.pow(levelTimeExponent, level);
  13.         //we want to converge on the right time by binary search
  14.         //could possibly do it directly with a formula, but this is easier to program
  15.         var low = 1;
  16.         var high = 500; //very difficult to actually exceed, so it serves as a suitable upper bound
  17.         //note with these values it is guaranteed to take 9 iterations
  18.         while(high - low > 1)
  19.         {
  20.             var middle = Math.ceil((low + high)/2);
  21.             var time = goalBuildingTime(level, bid, middle);
  22.             if(time > timeLevel)
  23.             {
  24.                 high = middle;
  25.             }
  26.             else
  27.             {
  28.                 low = middle;
  29.             }
  30.         }
  31.         return low;
  32.     };
  33.  
  34. goalBuildingTime =
  35.     function(level, bid, amount)
  36.     {
  37.         var baseCost = leveldata[level].buildings[bid].cost;
  38.         var purchaseRate = (bid + 1)*(bid + 1);
  39.         var exponent = 1.1 - 0.008*bid; //so in range [1.1, 1.028]
  40.         var numIgnored = Math.min(amount, exponentialIgnoreBuildings);
  41.         var numExponential = amount - numIgnored;
  42.        
  43.         var ignoredCost = baseCost*numIgnored;
  44.         var exponentialCost = baseCost*(1 - Math.pow(exponent, numExponential))/(1 - exponent);
  45.         var cost = ignoredCost + exponentialCost;
  46.         return cost/purchaseRate;
  47.     };
  48.  
  49. GoalBuildOne.prototype.create =
  50.     function(level)
  51.     {
  52.         this.level = level;
  53.         this.bid = index_roll(Math.random(), [1.000, 0.531, 0.375, 0.281, 0.214, 0.162, 0.120, 0.083, 0.052, 0.025]);
  54.         //default is: [1, 1/3, 1/5, 1/7, 1/9, 1/11, 1/13, 1/15, 1/17, 1/19]);
  55.         //delta between adjacent terms (and hence probability of picking them) corresponds to the original weightings
  56.         this.count = goalBuildingEquivalence(this.level, this.bid);
  57.     };
  58.  
  59. GoalBuildingIncome.prototype.create =
  60.     function(level)
  61.     {
  62.         this.level = level;
  63.         this.bid = index_roll(Math.random(), [1.000, 0.531, 0.375, 0.281, 0.214, 0.162, 0.120, 0.083, 0.052, 0.025]);
  64.         //default is the same as for GoalBuildOne
  65.         //hence the adjusted values are the same too
  66.         this.income = Math.floor(leveldata[this.level].buildings[this.bid].income*goalBuildingEquivalence(this.level, this.bid));
  67.         //default is: income*(200 - 20*bid + 100*level) = income*20*(10 - bid + 5*level)
  68.         //meaning you need to build (with no upgrades) 20 tier 10 buildings + 100 per level to complete a tier 10 objective (i.e. you need 320 to do it for a city)
  69.     };
  70.  
  71. GoalBuildAll.prototype.create =
  72.     function(level)
  73.     {
  74.         this.min = 0;
  75.         this.max = 4;
  76.         this.count = goalBuildingEquivalence(level, this.max);
  77.     };
Advertisement
Add Comment
Please, Sign In to add comment