Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // source: https://stackoverflow.com/a/49434653
- function randn_bm() {
- let u = 0, v = 0;
- while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
- while(v === 0) v = Math.random();
- let num = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
- num = num / 10.0 + 0.5; // Translate to 0 -> 1
- if (num > 1 || num < 0) return randn_bm() // resample between 0 and 1
- return num
- }
- // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
- function getRandomIntInclusive(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min + 1) + min); //The maximum is inclusive and the minimum is inclusive
- }
- function getRandomIntInclusiveNormal(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(randn_bm() * (max - min + 1) + min); //The maximum is inclusive and the minimum is inclusive
- }
- // random game time in minutes [min, max] uniform distribution
- function gameTimeMins(min, max) {
- var minMin = Math.round(min) * 60;
- var maxMin = Math.round(max) * 60;
- var gameTimeSeconds = getRandomIntInclusive(minMin, maxMin);
- return gameTimeSeconds / 60;
- }
- // random game time in minutes [min, max] normal distribution
- function gameTimeMinsNormal(min, max) {
- var minMin = Math.round(min) * 60;
- var maxMin = Math.round(max) * 60;
- var gameTimeSeconds = getRandomIntInclusiveNormal(minMin, maxMin);
- return gameTimeSeconds / 60;
- }
- // wr: win rate [0,1]
- function game(wr) {
- if (Math.random() < wr) {
- return 1;
- }
- return 0;
- }
- // points: mission points
- function completeBasicMission(points) {
- var games = 0;
- while (points > 0) {
- points -= 2 + 3 * game(0.5);
- games ++;
- }
- return games;
- }
- // target: misison points
- // win: points rate for win
- // loss: points rate for loss
- // avg: average game length
- // (un)comment the different length generation and rounding types to change the simulation
- function completePoints(target, win, loss, avg) {
- var games = 0;
- var points = 0;
- var length = avg;
- while (points < target) {
- // uniform
- length = gameTimeMins(avg * 0.5, avg * 1.5);
- // normal
- // length = gameTimeMinsNormal(avg * 0.5, avg * 1.5);
- // different rounding methods
- length = Math.round(length);
- // length = Math.ceil(length);
- // length = Math.floor(length);
- if (game(0.5)) {
- points += win * length;
- }
- else {
- points += loss * length;
- }
- games ++;
- }
- return games;
- }
- // tries: iterations to run
- // mission: mission points
- // avg: average game length
- function sim(tries, mission, avg){
- var totalGames = 0;
- for (var i = 0; i < tries; i ++) {
- totalGames += completePoints(mission, 6, 4, avg);
- }
- return totalGames/tries;
- }
- // tries: iterations to run
- // mission: mission points
- // avg: average game length
- // reward: tokens for completing mission
- function simTokens(tries, mission, avg, reward) {
- var gamesPerTokens = 0;
- for (var i = 0; i < tries; i ++) {
- gamesPerTokens += completePoints(mission, 6, 4, avg);
- }
- gamesPerTokens /= tries;
- return reward / gamesPerTokens;
- }
- // tries: iterations to run
- // mission: mission points
- function simOld(tries, mission){
- var totalGames = 0;
- for (var i = 0; i < tries; i ++) {
- totalGames += completeBasicMission(mission);
- }
- return totalGames / tries;
- }
- // tries: iterations to run
- // win: tokens for win
- // loss: tokens for loss
- function tokensOld(tries, win, loss) {
- var total = 0;
- for (var i = 0; i < tries; i ++) {
- if (game(0.5)) {
- total += win;
- } else {
- total += loss;
- }
- }
- return total / tries;
- }
- console.log("Old Weekly: ", simOld(25000000, 40));
- console.log("New Weekly ARAM: ", sim(25000000, 1650, 20));
- console.log("New Weekly SR: ", sim(25000000, 1650, 30));
- console.log("Old Orb Mission: 30");
- console.log("New Orb Mission ARAM: ", sim(25000000, 4500, 20));
- console.log("New Orb Mission SR: ", sim(25000000, 4500, 30));
- console.log("Old Tokens EV ARAM: ", tokensOld(25000000, 6, 3));
- console.log("New Tokens EV ARAM: ", simTokens(25000000, 400, 20, 20));
- console.log("Old Tokens EV SR: ", tokensOld(25000000, 10, 5));
- console.log("New Tokens EV SR: ", simTokens(25000000, 400, 30, 20));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement