Advertisement
Ashanmaril

Bug fusion simulation

Jul 25th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. /*
  2.     Tests whether progbot is a cheap ripoff or not
  3.     Runs 1000 simulations with 1000 bugfrags each and gives average tokens
  4.  
  5.     Written by Ashanmaril 7/25/2015
  6. */
  7.  
  8. #include <iostream>
  9. #include <time.h>
  10.  
  11. void bugFusion(int&, int&);
  12. void multiBugFusion(int&, int&);
  13.  
  14. int main()
  15. {
  16.     srand(int(time(0)));
  17.  
  18.     int bugFusionTotal = 0;
  19.     int multiBugFusionTotal = 0;
  20.  
  21.     for (int i = 0; i < 1000; i++)
  22.     {
  23.         //user 1 items
  24.         int bugFrags1 = 1000;
  25.         int tokens1 = 0;
  26.  
  27.         //user 2 items
  28.         int bugFrags2 = 1000;
  29.         int tokens2 = 0;
  30.  
  31.         while (bugFrags1 >= 5)
  32.             bugFusion(bugFrags1, tokens1);
  33.  
  34.         while (bugFrags2 >= 50)
  35.             multiBugFusion(bugFrags2, tokens2);
  36.  
  37.  
  38.         bugFusionTotal += tokens1;
  39.         multiBugFusionTotal += tokens2;
  40.     }
  41.  
  42.     int bugFusionAvg = bugFusionTotal / 1000;
  43.     int multiBugFusionAvg = multiBugFusionTotal / 1000;
  44.  
  45.     std::cout << "Average tokens with standard bug fusion: " << bugFusionAvg << std::endl;
  46.     std::cout << "Average tokens with multi bug fusion: " << multiBugFusionAvg << std::endl;
  47.  
  48.     return 0;
  49. }
  50.  
  51. void bugFusion(int& f, int& t)
  52. {
  53.  
  54.     if (f < 5)
  55.     {
  56.         //not enough frags
  57.     }
  58.     else
  59.     {
  60.         f -= 5;
  61.         int r = rand() % 10;
  62.         if (r < 8) //success
  63.         {
  64.             t++; //get a token
  65.         }
  66.         else
  67.         {
  68.             //failed
  69.         }
  70.     }
  71. }
  72.  
  73. void multiBugFusion(int& f, int& t)
  74. {
  75.     if (f < 50)
  76.     {
  77.         //not enough frags
  78.     }
  79.     else
  80.     {
  81.         f -= 50;
  82.         int r = rand() % 10;
  83.         if (r < 9) //success
  84.         {
  85.             t += 10; //get 10 tokens
  86.         }
  87.         else
  88.         {
  89.             //failed
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement