Guest User

Untitled

a guest
Feb 19th, 2013
1,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. # Author:      Nozdrum
  2.  
  3. avgExoticValue = 30000 #3g
  4. avgRareValue = 5000 #50s
  5. precursorProbablity = 0.005 #not really important, since it does not impact the choice, just how much you have to pay in the end
  6.  
  7. class Item:
  8.     minCost = 0 # Minimal cost of an item to be put in the mystic forge
  9.     exoticProbablity = 0 # Probablity that this will yield in an exotic
  10.     n = 0.0 # Average Number of attempts
  11.  
  12.     # compute average number of attempts at the mystic forge
  13.     def attempts(self):
  14.         self.n =  1 / (self.exoticProbablity * precursorProbablity )
  15.  
  16.     def avgCostPerPrecursor(self):
  17.         costToProduce = (4*self.minCost * self.n)
  18.         rakeBackExotic = ( avgExoticValue * ( self.n * self.exoticProbablity )) # average Value of exotics you get
  19.         rakeBackRare = ( avgRareValue * ( self.n * ( 1- self.exoticProbablity ))) # average Value of rares you get
  20.  
  21.         return costToProduce - rakeBackRare - rakeBackExotic
  22.  
  23. class Rare(Item):
  24.  
  25.     def __init__(self):
  26.         self.exoticProbablity = 0.2 # Every fifth attempt yields an exotic
  27.         self.minCost = 4000 #40 Silver
  28.         self.attempts()
  29.  
  30. class Exotic(Item):
  31.     def __init__(self):
  32.         self.exoticProbablity = 1 #Exotics always yield exotics
  33.         self.minCost = 24000 #2g40s
  34.         self.attempts()
  35.  
  36. def pretty(number):
  37.     copper = format((number % 100),".0f") + "c"
  38.     number = number / 100
  39.     silver = format(number % 100,".0f") + "s"
  40.     number = number / 100
  41.     return format(number,".0f") + "g"+silver +copper
  42.  
  43. rare = Rare()
  44. exotic = Exotic()
  45.  
  46. print("Rare: Average Number of attempts: " + str(rare.n) + " avgCostPerPrecursor: " + pretty(rare.avgCostPerPrecursor()))
  47. print("Exotic: Average Number of attempts: " + str(exotic.n) + " avgCostPerPrecursor: " + pretty(exotic.avgCostPerPrecursor()))
Advertisement
Add Comment
Please, Sign In to add comment