Created
August 26, 2022 13:55
-
-
Save vip3r011/7d5d662690a4fe1145cdb46eec0e7822 to your computer and use it in GitHub Desktop.
3reel slot calc.
This file contains hidden or 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
/* 3 reel slot, no wilds, no scatter*/ | |
function occur(array){ | |
const occurrences = array.reduce(function (acc, curr) { | |
return acc[curr] ? ++acc[curr] : acc[curr] = 1, acc | |
}, {}); | |
return occurrences; | |
} | |
const reels = [ | |
[6,2,2,2,2,4,4,8,1,1,1,1,0,7,0,0,0,0,5,5,3,3,3,3], | |
[7,6,2,6,2,2,2,4,1,4,1,1,1,0,8,0,0,0,5,3,5,3,3,3], | |
[0,0,0,0,5,5,8,3,3,3,3,6,6,2,2,2,2,4,4,1,1,1,1,1,0,7] | |
]; | |
const paytable = [40, 40, 40, 40, 80, 80, 100, 200, 300]; | |
const OCCURRENCES = []; | |
for (let reel = 0; reel < reels.length; ++reel) { | |
OCCURRENCES.push(occur(reels[reel])) | |
} | |
const reducer = (accumulator, curr) => accumulator + curr; | |
let TOTALCOMBO = 1; | |
const COUNTS = new Array(9); | |
COUNTS.fill(1,0,9); | |
for (let o = 0; o < OCCURRENCES.length; ++o) { | |
let values = Object.values(OCCURRENCES[o]); | |
TOTALCOMBO *= values.reduce(reducer); | |
for (let s = 0; s < values.length; ++s) { | |
COUNTS[s] *= values[s]; | |
} | |
} | |
const HITS = new Array(9); | |
HITS.fill(0,0,9); | |
for (let s = 0; s < COUNTS.length; ++s) { | |
HITS[s] = COUNTS[s]/TOTALCOMBO | |
} | |
let RTP=0; | |
const PERC = new Array(9); | |
PERC.fill(0,0,9); | |
for (let s = 0; s < HITS.length; ++s) { | |
PERC[s] = HITS[s]*paytable[s]; | |
RTP += HITS[s]*paytable[s]; | |
} | |
//0.9682158119658119 | |
console.log(RTP); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment