Advertisement
Guest User

CSGO500 - Prediction Script [Zano]

a guest
Jul 23rd, 2017
2,877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.69 KB | None | 0 0
  1. //CSGO500 Betting Assistant
  2. // By Zano
  3. // http://steamcommunity.com/id/zano-c
  4.  
  5. //Supporting Functions
  6. function countOccurences(array_raw, item){
  7. var occurences = 0
  8. for(var i = 0; i < array_raw.length; i++) {
  9. if(array_raw[i] == item){
  10. occurences += 1
  11. }
  12. }
  13. return occurences
  14. }
  15. //Get key with highest value in dict
  16. function dictMax(o){
  17. var vals = [];
  18. for(var i in o){
  19. vals.push(o[i]);
  20. }
  21.  
  22. var max = Math.max.apply(null, vals);
  23.  
  24. for(var i in o){
  25. if(o[i] == max){
  26. return i;
  27. }
  28. }
  29. }
  30.  
  31. //Color list
  32. var color_list = ["black","red","blue","gold"]
  33.  
  34. //Fetch History (Last 100)
  35. function getHistory(){
  36. //Get raw node list
  37. var node_list = $("#past-queue-wrapper").children()
  38. var roll_history = []
  39. node_list.each(function(){
  40. //Convert Nodes to Color String
  41. var style_text = $(this).attr("class")
  42. var color_int = Number(style_text.charAt(5))
  43. //Append to history list
  44. roll_history.push(color_list[color_int])
  45. })
  46. //Return roll_history
  47. return roll_history
  48. }
  49.  
  50. //Get current roll
  51. function getRoll(){
  52. return color_list[winner.choice]
  53. }
  54.  
  55. //Calculate Differences between Theoeretical occurences and real occurences
  56. function calculateDifference(){
  57. var theoretical_occurences = {
  58. "black": (26/54.0) * 100,
  59. "red": (17/54.0) * 100,
  60. "blue": (10/54.0) * 100,
  61. "gold": (1/54.0) * 100
  62. }
  63.  
  64. var roll_history = getHistory()
  65.  
  66. var actual_occurences = {
  67. "black": countOccurences(roll_history, "black"),
  68. "red": countOccurences(roll_history, "red"),
  69. "blue": countOccurences(roll_history, "blue"),
  70. "gold": countOccurences(roll_history, "gold")
  71. }
  72.  
  73. var differences = {
  74. "black": Number((theoretical_occurences["black"] - actual_occurences["black"]).toFixed(1)),
  75. "red": Number((theoretical_occurences["red"] - actual_occurences["red"]).toFixed(1)),
  76. "blue": Number((theoretical_occurences["blue"] - actual_occurences["blue"]).toFixed(1)),
  77. "gold": Number((theoretical_occurences["gold"] - actual_occurences["gold"]).toFixed(1))
  78. }
  79. return differences
  80. }
  81.  
  82. //Use differences to calculate percentage chances
  83. function calculatePercentages(){
  84. var difference = calculateDifference()
  85.  
  86. var offset = Math.abs(Math.min(difference["black"],difference["red"], difference["blue"], difference["gold"]))
  87. var scale = Math.abs(Math.max(difference["black"],difference["red"], difference["blue"], difference["gold"]))/4
  88. var scalars = {
  89. "black": 2.8,
  90. "red": 2.5,
  91. "blue": 2.3,
  92. "gold": 2
  93. }
  94. var newDifferences = {
  95. "black": difference["black"] + (1/scale * Math.pow(offset,4))*scalars["black"],
  96. "red": difference["red"] + (1/scale * Math.pow(offset,4))*scalars["red"],
  97. "blue": difference["blue"]+ (1/scale * Math.pow(offset,4))*scalars["blue"],
  98. "gold": difference["gold"] + (1/scale * Math.pow(offset,4))*scalars["gold"]
  99. }
  100.  
  101. var total = Number(newDifferences["black"]) + Number(newDifferences["red"]) + Number(newDifferences["blue"]) + Number(newDifferences["gold"])
  102.  
  103. var newDifferences = {
  104. "black": newDifferences["black"]/total,
  105. "red": newDifferences["red"]/total,
  106. "blue": newDifferences["blue"]/total,
  107. "gold": newDifferences["gold"]/total
  108. }
  109. return newDifferences
  110.  
  111.  
  112. }
  113. //==================================================================
  114. //GUI
  115. //================================================
  116. var color_codes = ["rgb(80, 80, 80)","rgb(200, 53, 78)","rgb(69, 181, 218)","rgb(219, 192, 127)"];
  117. var color_codes_dict = {"black":"rgb(80, 80, 80)","red":"rgb(200, 53, 78)","blue":"rgb(69, 181, 218)","gold":"rgb(219, 192, 127)"};
  118.  
  119. //Append Styles
  120. $("head").append("<style></style>")
  121. //Create Box
  122. $("#balance-wrapper").parent().prepend('<div id="assistant" style="width:300px;height:200px;background: #2C2C32;border-radius:5px;margin:auto; margin-bottom:20px;"><div id="spoiler" style="background: rgb(80, 80, 80); width: 10px; height: 10px; float: right; border-radius: 5px; margin: 10px;margin-left:280px;position:absolute;"></div><div id="prediction-container" style="padding-top: 20px;display: flex;"><div id="prediction-large" style="width:50%;height:50px"><h2 style="color:rgb(200, 53, 78); text-align:right; " id="prediction-large-text"><div id="prediction-large-ball" style="margin-right:-10px;margin-left:10px;margin-top: 0px;background: rgb(200, 53, 78); width: 40px; height: 40px; float: right; border-radius: 30px;"></div>0% </h2></div><div id="prediction-small" style="width:50%;height:50px"><h2 style="color:rgb(69, 181, 218); text-align:left;" id="prediction-small-text"><div id="prediction-small-ball" style="border: solid 2px #2C2C32;margin-right:10px;margin-left:-10px;margin-top: 5px;background: rgb(69, 181, 218); width: 30px; height: 30px; float: left; border-radius: 30px;"></div>0%</h2></div></div><div id="accuracy-container" style="padding-top: 20px;"><h2 id="accuracy" style="margin:auto;text-align:center;color:#666;">0%</h2><p style="text-align:center;margin:auto;color:#666;">CORRECT</p></div><div id="credits" style="position:absolute;height:25px;width:300px;margin-top:0px;"><p style="text-align:center;color:#666;">Prediction Script by<a href="http://steamcommunity.com/id/zano-c" target="_blank"> Zano. </a><a style="padding-left: 10px;" href="https://steamcommunity.com/tradeoffer/new/?partner=94808127&token=reBoxNia" target="_blank"> Donate </a></p></div></div>')
  123.  
  124. var correct = 1
  125. var rolls = 1
  126.  
  127. var highest = {}
  128. var lowest = {}
  129.  
  130. function update(){
  131. var winner_temp = winner.choice
  132. var time = Number($("#wheel-timer").text())
  133. //Once every round
  134. if(time > 18.5){
  135. if(color_list[winner_temp] == highest.color || color_list[winner_temp] == lowest.color){
  136. correct = correct + 1
  137. }
  138. rolls = rolls + 1
  139. }
  140.  
  141. var pred_list = calculatePercentages()
  142. var pred_list_lower = calculatePercentages()
  143. pred_list_lower[dictMax(pred_list)] = 0
  144. //Get predictions
  145. var predictions = [{"color":dictMax(pred_list),"value":pred_list[dictMax(pred_list)]},{"color":dictMax(pred_list_lower),"value":pred_list[dictMax(pred_list_lower)]}]
  146.  
  147. //Sort preditctions by highest and lowest
  148.  
  149. if(predictions[0]["value"] > predictions[1]["value"]){
  150. highest = predictions[0]
  151. lowest = predictions[1]
  152. }else{
  153. highest = predictions[1]
  154. lowest = predictions[0]
  155. }
  156.  
  157.  
  158. if(time > 0){
  159. winner = ""
  160. $("#spoiler").css("background",winner_temp)
  161.  
  162. }else{
  163. //Update spoiler
  164. winner_temp = winner.choice
  165. $("#spoiler").css("background",color_codes[winner_temp])
  166. }
  167.  
  168.  
  169.  
  170.  
  171.  
  172. //Update Box
  173.  
  174. //Update Ball Colors
  175. $("#prediction-large-ball").css("background",color_codes_dict[highest.color])
  176. $("#prediction-small-ball").css("background",color_codes_dict[lowest.color])
  177.  
  178. //Update Text Values
  179. var inner = ""
  180. $("#prediction-large-text").children().each(function() {
  181. inner = inner + this.outerHTML;
  182. });
  183. inner = inner + (highest.value * 100).toFixed(0) + "%"
  184. $("#prediction-large-text").html(inner)
  185.  
  186. var inner = ""
  187. $("#prediction-small-text").children().each(function() {
  188. inner = inner + this.outerHTML;
  189. });
  190. inner = inner + (lowest.value * 100).toFixed(0) + "%"
  191. $("#prediction-small-text").html(inner)
  192.  
  193. //Update Text Colors
  194. $("#prediction-large-text").css("color",color_codes_dict[highest.color])
  195. $("#prediction-small-text").css("color",color_codes_dict[lowest.color])
  196.  
  197. //Update Correct Percentage
  198. $("#accuracy").text(Number(correct/rolls * 100).toFixed(1) + "%")
  199. }
  200.  
  201. //Begin
  202. $( "#spoiler" ).click(function() {
  203. console.log("Debug:")
  204. console.log("Predicted " + String(correct) + "/" + String(rolls) + " rolls correctly")
  205. console.log("Correct: " + String(Number(correct/rolls * 100).toFixed(1) + "%"))
  206. console.log("Prediction Values: " )
  207. console.log(calculatePercentages())
  208. });
  209. setInterval(update,1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement