Chance calculator for MTG Traumatize Deck
by skibulk
JavaScript
console.clear();
// 1 = Dread Return
// 2 = Scholar of the Lost Trove
// 3 = Twilight's Call / Living Death
var deck = [1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,3];
deck.length = 200;
// 7-card starting hand
// 5 turns of draws
// 1 search
var stop = 13 + Math.floor((deck.length - 13)/2);
var trials = 10000;
var successes = 0;
var dreadSuccess = 0;
for(var i = 0; i < trials; i++){
shuffle(deck);
var a = false;
var b = false;
var c = false;
for(var j=0; j<stop; j++){
if(deck[j] == 1) {
a = true;
} else if(deck[j] == 2) {
b = true;
} else if(deck[j] == 3) {
c = true;
}
}
if(a & b & c){
successes++;
}
if(a){
// console.log(a);
dreadSuccess++;
}
}
console.log({
deck: deck,
stop: stop,
successes: Math.round(successes / trials * 10000) / 100,
dreadSuccess: Math.round(dreadSuccess / trials * 10000) / 100
});
// https://stackoverflow.com/a/2450976/1017480
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}