Advertisement
Guest User

Untitled

a guest
Jul 6th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.82 KB | None | 0 0
  1. object Main extends App{
  2.  
  3.   val startDate: Int = 7  // Days from 29 Jun 2018 (can't be 0)
  4.   val targetDate: Int = 695 // Total days from 29 June 2028 to 25 May 2020
  5.   val deplenishRate: Int = 70
  6.   val rewards: Seq[Float] = Seq[Float](60, 54, 48, 42, 36, 30, 24, 24, 18, 12, 6, 0.00075f)
  7.   val maxPhase: Int = 14
  8.  
  9.   val startQty: Float = 1000000
  10.   val startMn: Int = 100
  11.  
  12.   val targetNumberOfMN = Seq(1800,2200,2600) // Tweakable
  13.   val blocksPerDay: Float = 1440
  14.  
  15.   for(j <- 0 until 3) {
  16.  
  17.     val initialValueOfMN = 1400 // As 30 June2018
  18.     var curMn: Int = startMn
  19.     var curQty: Float = startQty
  20.     var rewardIndex: Int = 0
  21.     var curPhase = 3
  22.  
  23.     def totalNumberOfMN(day: Float, iteration: Int) = Math.ceil(initialValueOfMN + (targetNumberOfMN(iteration) - initialValueOfMN)*(day/targetDate)).toInt
  24.  
  25.  
  26.     println(s"iteration: $j, number of MN raising to ${targetNumberOfMN(j)}")
  27.     println(s"Starting from $startDate days after 29 Jun 2018 with $curMn MN and $curQty QTY")
  28.  
  29.     for(i <- startDate until targetDate) {
  30.       curQty += (rewards(Math.min(rewardIndex, rewards.size-1)) *curMn)*(blocksPerDay/totalNumberOfMN(i, j))
  31.  
  32.       if(curQty >= 10000*(curMn +1)) {
  33.         curMn+=1
  34.       }
  35.  
  36.       if(i%deplenishRate == 0 && curPhase != maxPhase){
  37.         rewardIndex+=1
  38.         println(s"Day $i, End of phase $curPhase, curMn: $curMn, total gain: $curQty")
  39.         println(s"Projected total number of MN in the world: ${totalNumberOfMN(i, j)}")
  40.         curPhase+=1
  41.       }
  42.  
  43.     }
  44.     println(s"Final total amount of MN in the world: ${targetNumberOfMN(j)}")
  45.     println(s"Final MN count after ${targetDate - startDate} days: $curMn")
  46.     println(s"Final QTY count after ${targetDate - startDate} days: $curQty")
  47.     println("//===============================================================//")
  48.   }
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement