This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseENV(content) { | |
var contentArray = content.split('\n') | |
var contentDict = {} | |
for (var i = 0; i < contentArray.length; i++) { | |
if (contentArray[i] === '') { continue } | |
contentArray[i].replace('\r', '') | |
contentArray[i].trim() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function eloRating(player, opponent, score, K = 20) { | |
// Score is 1 if player won, 0 if opponent won, and 0.5 if a draw | |
// Information: https://www.omnicalculator.com/sports/elo | |
let difference = K * (score - (1 / (1 + 10**((opponent - player)/400)))) | |
difference = Math.round(Math.abs(difference)) | |
if (score >= 1) { | |
player += difference | |
opponent -= difference | |
} else if (score <= 0) { |