Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CSGO500 Betting Assistant
- // By Zano
- // http://steamcommunity.com/id/zano-c
- //Supporting Functions
- function countOccurences(array_raw, item){
- var occurences = 0
- for(var i = 0; i < array_raw.length; i++) {
- if(array_raw[i] == item){
- occurences += 1
- }
- }
- return occurences
- }
- //Get key with highest value in dict
- function dictMax(o){
- var vals = [];
- for(var i in o){
- vals.push(o[i]);
- }
- var max = Math.max.apply(null, vals);
- for(var i in o){
- if(o[i] == max){
- return i;
- }
- }
- }
- //Color list
- var color_list = ["black","red","blue","gold"]
- //Fetch History (Last 100)
- function getHistory(){
- //Get raw node list
- var node_list = $("#past-queue-wrapper").children()
- var roll_history = []
- node_list.each(function(){
- //Convert Nodes to Color String
- var style_text = $(this).attr("class")
- var color_int = Number(style_text.charAt(5))
- //Append to history list
- roll_history.push(color_list[color_int])
- })
- //Return roll_history
- return roll_history
- }
- //Get current roll
- function getRoll(){
- return color_list[winner.choice]
- }
- //Calculate Differences between Theoeretical occurences and real occurences
- function calculateDifference(){
- var theoretical_occurences = {
- "black": (26/54.0) * 100,
- "red": (17/54.0) * 100,
- "blue": (10/54.0) * 100,
- "gold": (1/54.0) * 100
- }
- var roll_history = getHistory()
- var actual_occurences = {
- "black": countOccurences(roll_history, "black"),
- "red": countOccurences(roll_history, "red"),
- "blue": countOccurences(roll_history, "blue"),
- "gold": countOccurences(roll_history, "gold")
- }
- var differences = {
- "black": Number((theoretical_occurences["black"] - actual_occurences["black"]).toFixed(1)),
- "red": Number((theoretical_occurences["red"] - actual_occurences["red"]).toFixed(1)),
- "blue": Number((theoretical_occurences["blue"] - actual_occurences["blue"]).toFixed(1)),
- "gold": Number((theoretical_occurences["gold"] - actual_occurences["gold"]).toFixed(1))
- }
- return differences
- }
- //Use differences to calculate percentage chances
- function calculatePercentages(){
- var difference = calculateDifference()
- var offset = Math.abs(Math.min(difference["black"],difference["red"], difference["blue"], difference["gold"]))
- var scale = Math.abs(Math.max(difference["black"],difference["red"], difference["blue"], difference["gold"]))/4
- var scalars = {
- "black": 2.8,
- "red": 2.5,
- "blue": 2.3,
- "gold": 2
- }
- var newDifferences = {
- "black": difference["black"] + (1/scale * Math.pow(offset,4))*scalars["black"],
- "red": difference["red"] + (1/scale * Math.pow(offset,4))*scalars["red"],
- "blue": difference["blue"]+ (1/scale * Math.pow(offset,4))*scalars["blue"],
- "gold": difference["gold"] + (1/scale * Math.pow(offset,4))*scalars["gold"]
- }
- var total = Number(newDifferences["black"]) + Number(newDifferences["red"]) + Number(newDifferences["blue"]) + Number(newDifferences["gold"])
- var newDifferences = {
- "black": newDifferences["black"]/total,
- "red": newDifferences["red"]/total,
- "blue": newDifferences["blue"]/total,
- "gold": newDifferences["gold"]/total
- }
- return newDifferences
- }
- //==================================================================
- //GUI
- //================================================
- var color_codes = ["rgb(80, 80, 80)","rgb(200, 53, 78)","rgb(69, 181, 218)","rgb(219, 192, 127)"];
- var color_codes_dict = {"black":"rgb(80, 80, 80)","red":"rgb(200, 53, 78)","blue":"rgb(69, 181, 218)","gold":"rgb(219, 192, 127)"};
- //Append Styles
- $("head").append("<style></style>")
- //Create Box
- $("#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>')
- var correct = 1
- var rolls = 1
- var highest = {}
- var lowest = {}
- function update(){
- var winner_temp = winner.choice
- var time = Number($("#wheel-timer").text())
- //Once every round
- if(time > 18.5){
- if(color_list[winner_temp] == highest.color || color_list[winner_temp] == lowest.color){
- correct = correct + 1
- }
- rolls = rolls + 1
- }
- var pred_list = calculatePercentages()
- var pred_list_lower = calculatePercentages()
- pred_list_lower[dictMax(pred_list)] = 0
- //Get predictions
- var predictions = [{"color":dictMax(pred_list),"value":pred_list[dictMax(pred_list)]},{"color":dictMax(pred_list_lower),"value":pred_list[dictMax(pred_list_lower)]}]
- //Sort preditctions by highest and lowest
- if(predictions[0]["value"] > predictions[1]["value"]){
- highest = predictions[0]
- lowest = predictions[1]
- }else{
- highest = predictions[1]
- lowest = predictions[0]
- }
- if(time > 0){
- winner = ""
- $("#spoiler").css("background",winner_temp)
- }else{
- //Update spoiler
- winner_temp = winner.choice
- $("#spoiler").css("background",color_codes[winner_temp])
- }
- //Update Box
- //Update Ball Colors
- $("#prediction-large-ball").css("background",color_codes_dict[highest.color])
- $("#prediction-small-ball").css("background",color_codes_dict[lowest.color])
- //Update Text Values
- var inner = ""
- $("#prediction-large-text").children().each(function() {
- inner = inner + this.outerHTML;
- });
- inner = inner + (highest.value * 100).toFixed(0) + "%"
- $("#prediction-large-text").html(inner)
- var inner = ""
- $("#prediction-small-text").children().each(function() {
- inner = inner + this.outerHTML;
- });
- inner = inner + (lowest.value * 100).toFixed(0) + "%"
- $("#prediction-small-text").html(inner)
- //Update Text Colors
- $("#prediction-large-text").css("color",color_codes_dict[highest.color])
- $("#prediction-small-text").css("color",color_codes_dict[lowest.color])
- //Update Correct Percentage
- $("#accuracy").text(Number(correct/rolls * 100).toFixed(1) + "%")
- }
- //Begin
- $( "#spoiler" ).click(function() {
- console.log("Debug:")
- console.log("Predicted " + String(correct) + "/" + String(rolls) + " rolls correctly")
- console.log("Correct: " + String(Number(correct/rolls * 100).toFixed(1) + "%"))
- console.log("Prediction Values: " )
- console.log(calculatePercentages())
- });
- setInterval(update,1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement