SHARE
TWEET

MtG Arena Standard 2020 average XP per game

a guest Sep 18th, 2019 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     output:
  3.     {
  4.         0.50 old:           33.333333333333336,
  5.         0.55 old:           39.032258064516135,
  6.         0.60 old:           45,
  7.  
  8.         0.50 new:           38,
  9.         0.55 new:           42.56189807774788,
  10.         0.60 new:           47.1638141809291,
  11.  
  12.         0.50 better new:    38.888888888888886,
  13.         0.55 better new:    43.407629887237846,
  14.         0.60 better new:    47.94212218649518,
  15.     }
  16. */
  17.  
  18. const oldOutcomes = {
  19.     ww:  200,
  20.     wl:    0,
  21.     l:     0,
  22. };
  23.  
  24. const newOutcomes = {
  25.     www:  250,  // 3 wins
  26.     wwlw: 250,
  27.     wlww: 250,
  28.     lwww: 250,
  29.  
  30.     wwll: 150,  // 2 wins
  31.     wlwl: 150,
  32.     lwwl: 150,
  33.  
  34.     wll:   50,  // 1 win
  35.     lwl:   50,
  36.  
  37.     ll:     0,  // 0 wins
  38. };
  39.  
  40. const betterNewOutcomes = {
  41.     www:  250,  // 3 wins
  42.     wwlw: 250,
  43.     wlww: 250,
  44.  
  45.     wwll: 150,  // 2 wins
  46.     wlwl: 150,
  47.  
  48.     wll:   50,  // 1 win
  49.  
  50.     l:      0,  // 0 wins
  51. };
  52.  
  53. function averagePrizePerGame (outcomes, winProb) {
  54.  
  55.     for (const [gameRecord, prize] of Object.entries(outcomes)) {
  56.         let wins = 0;
  57.         let losses = 0;
  58.  
  59.         for (const g of gameRecord) {
  60.             switch (g) {
  61.                 case "w": wins++; break;
  62.                 case "l": losses++; break;
  63.                 default: throw new Error(`Unknown game result: ${g}`);
  64.             }
  65.         }
  66.  
  67.         const probability = Math.pow(winProb, wins) * Math.pow(1 - winProb, losses);
  68.         const length = gameRecord.length;
  69.         outcomes[gameRecord] = {prize, probability, length};
  70.     }
  71.  
  72.     const highestLength = Math.max( ...Object.values(outcomes).map( ({length}) => length ) );
  73.  
  74.     //     averagePrizePerGame = SUM: probability * (prize + (highestLength - length) * averagePrizePerGame) / highestLength
  75.  
  76.     //                         =                       SUM: probability * prize / highestLength +
  77.     //                           averagePrizePerGame * SUM: probability * (1 - length / highestLength)
  78.  
  79.     // <=> (1 - SUM: probability * (1 - length / highestLength)) *  averagePrizePerGame = SUM: probability * prize / highestLength
  80.  
  81.     // <=> averagePrizePerGame = (  SUM: probability * prize / highestLength  ) / (  1 - SUM: probability * (1 - length / highestLength)  )
  82.  
  83.     //                         = (  SUM: probability * prize  ) / (  highestLength - SUM: probability * (highestLength - length)  )
  84.  
  85.     const sum1   = Object.values(outcomes).reduce(
  86.         (acc, {prize, probability, length}) => acc + probability * prize,
  87.         0
  88.     );
  89.     const sum2 = Object.values(outcomes).reduce(
  90.         (acc, {prize, probability, length}) => acc + probability * (highestLength - length),
  91.         0
  92.     );
  93.  
  94.     return sum1 / (highestLength - sum2);
  95. }
  96.  
  97. return {
  98.     "0.50 old":        averagePrizePerGame({...oldOutcomes}, 0.5),
  99.     "0.55 old":        averagePrizePerGame({...oldOutcomes}, 0.55),
  100.     "0.60 old":        averagePrizePerGame({...oldOutcomes}, 0.6),
  101.     "0.50 new":        averagePrizePerGame({...newOutcomes}, 0.5),
  102.     "0.55 new":        averagePrizePerGame({...newOutcomes}, 0.55),
  103.     "0.60 new":        averagePrizePerGame({...newOutcomes}, 0.6),
  104.     "0.50 better new": averagePrizePerGame({...betterNewOutcomes}, 0.5),
  105.     "0.55 better new": averagePrizePerGame({...betterNewOutcomes}, 0.55),
  106.     "0.60 better new": averagePrizePerGame({...betterNewOutcomes}, 0.6),
  107. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top