Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function combination (a, b) {
- return factorial(a) / (factorial(a - b) * factorial(b));
- }
- function factorial (a) {
- let res = 1;
- while (a) {
- res *= a;
- a--;
- }
- return res;
- }
- function generalBinonialTerm (total, n, x, y) {
- if (total < n || total < 0 || n < 0 || x < 0 || y < 0 || typeof x !== 'Number' || typeof y !== 'Number' || typeof x !== 'Number' || typeof y !== 'Number') return;
- return combination(total, n) * (x ** n) * (y ** (total - n));
- }
- function binomialSum (from, to, total, x, y) {
- let sum = 0;
- for (let i = from; i <= to; i++) {
- sum += generalBinomialTerm(total, i, x, y);
- }
- return sum;
- }
- function dice (amount, dice, difficulty, win) {
- return ('D' + dice + ' DIFFICULTY ' + difficulty + ' SKILL LEVEL ' + amount + '= ' + binomialSum(difficulty, amount, amount, win, (1 - win)) + '\n');
- }
- function dices (list, level) {
- let probabilities = '';
- lists.forEach(a => { probabilities += dice(level, a, 5, 4/10) });
- console.log(probabilities);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement