wooferzfg1

Mustache Girl Simulation

Dec 31st, 2017
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace MafiaBoss
  6. {
  7. class MustacheGirl
  8. {
  9. static List<int> currentBossAttacks;
  10. static int mode = -1;
  11. static int cycle = 0;
  12. static int bossTurn = -1;
  13. static int currentBossAttack = -1;
  14. static Random rnd;
  15.  
  16. static bool IsBossAttackAllowed(int attackID, int indexInArray, int currentTurn)
  17. {
  18. if (currentBossAttack == attackID && indexInArray == 0) return false;
  19. return true;
  20. }
  21.  
  22. static int PullRandomBossAttack(int maxAttackID)
  23. {
  24. if (currentBossAttacks.Count <= 0)
  25. {
  26. bossTurn++;
  27. List<int> potentialAttackIDs = new List<int>();
  28. for (int i = 0; i <= maxAttackID; i++)
  29. potentialAttackIDs.Add(i);
  30. while (potentialAttackIDs.Count > 0)
  31. {
  32. int i = rnd.Next(potentialAttackIDs.Count);
  33. if (!IsBossAttackAllowed(potentialAttackIDs[i], currentBossAttacks.Count, bossTurn)) continue;
  34. currentBossAttacks.Add(potentialAttackIDs[i]);
  35. potentialAttackIDs.RemoveAt(i);
  36. }
  37. }
  38. if (currentBossAttacks.Count <= 0) return -1;
  39.  
  40. int firstAttack = currentBossAttacks[0];
  41. currentBossAttacks.RemoveAt(0);
  42. return firstAttack;
  43. }
  44.  
  45. static void clearBossAttacksOnNewMode()
  46. {
  47. bossTurn = -1;
  48. currentBossAttack = -1;
  49. currentBossAttacks = new List<int>();
  50. }
  51.  
  52. static void advanceMode()
  53. {
  54. mode++;
  55. cycle = 0;
  56. clearBossAttacksOnNewMode();
  57. }
  58.  
  59. static void Main(string[] args)
  60. {
  61. IDictionary<int, int> results = new Dictionary<int, int>();
  62. rnd = new Random();
  63.  
  64. for (int i = 0; i < 10000000; i++)
  65. {
  66. int cherries = 1;
  67. bool hasBubble = true;
  68. mode = -1;
  69.  
  70. //Mode A
  71. advanceMode();
  72. int bossHealth = 8;
  73. while (bossHealth > 0 || bossTurn == 0)
  74. {
  75. currentBossAttack = PullRandomBossAttack(5);
  76. if (currentBossAttack <= 1 && !hasBubble)
  77. {
  78. //Create Bubble
  79. hasBubble = true;
  80. cherries++;
  81. }
  82. else if (currentBossAttack == 2)
  83. {
  84. //Teleport Slap
  85. if (hasBubble)
  86. {
  87. hasBubble = false;
  88. bossHealth -= 2;
  89. }
  90. else
  91. bossHealth--;
  92. }
  93. else if (currentBossAttack == 3)
  94. {
  95. //Underground
  96. if (hasBubble)
  97. {
  98. hasBubble = false;
  99. bossHealth -= 2;
  100. }
  101. else
  102. bossHealth--;
  103.  
  104. }
  105. else if (currentBossAttack == 4)
  106. {
  107. //Big Laser
  108. if (hasBubble)
  109. {
  110. hasBubble = false;
  111. bossHealth -= 2;
  112. }
  113. else
  114. bossHealth--;
  115.  
  116. }
  117. else if (currentBossAttack == 5)
  118. {
  119. //Shock Waves
  120. if (hasBubble)
  121. {
  122. hasBubble = false;
  123. bossHealth -= 2;
  124. }
  125. else
  126. bossHealth--;
  127. }
  128. }
  129.  
  130. if (!results.ContainsKey(cherries))
  131. results[cherries] = 1;
  132. else
  133. results[cherries]++;
  134. }
  135.  
  136. foreach (KeyValuePair<int, int> kvp in results.OrderBy(x => x.Key))
  137. {
  138. Console.WriteLine("Cherries: {0} - {1}", kvp.Key, kvp.Value);
  139. }
  140.  
  141. while (true) { }
  142. }
  143. }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment