JavaScript
Array.prototype.random = function () {
return this[Math.floor((Math.random()*this.length))];
}
let finalCount = {
"common": 0,
"uncommon": 0,
"rare": 0,
"strange": 0,
"unprecedented": 0,
"bizarre": 0
}
const situations_common = [
{t: "common 0"},
{t: "common 1"},
{t: "common 2"},
{t: "common 3"},
{t: "common 4"},
{t: "common 5"},
{t: "common 6"},
{t: "common 7"},
{t: "common 8"},
{t: "common 9"},
{t: "common 10"},
{t: "common 11"},
{t: "common 12"},
{t: "common 13"},
{t: "common 14"},
{t: "common 15"},
{t: "common 16"},
{t: "common 17"},
{t: "common 18"},
{t: "common 19"}
];
const situations_uncommon = [
{t: "uncommon 0"},
{t: "uncommon 1"},
{t: "uncommon 2"},
{t: "uncommon 3"},
{t: "uncommon 4"},
{t: "uncommon 5"},
{t: "uncommon 6"},
{t: "uncommon 7"},
{t: "uncommon 8"},
{t: "uncommon 9"}
];
const situations_rare = [
{t: "rare 0"},
{t: "rare 1"},
{t: "rare 2"},
{t: "rare 3"},
{t: "rare 4"},
{t: "rare 5"},
{t: "rare 6"},
];
const situations_strange = [
{t: "strange 0"},
{t: "strange 1"},
{t: "strange 2"},
{t: "strange 3"}
];
const situations_unprecedented = [
{t: "unprecedented 0"},
{t: "unprecedented 1"},
{t: "unprecedented 2"},
];
const situations_bizarre = [
{t: "bizarre 0"},
{t: "bizarre 1"}
];
const occurances = [
{n: "bizarre", p: 1, s: situations_bizarre},
{n: "unprecedented", p: 3, s: situations_unprecedented},
{n: "strange", p: 6, s: situations_strange},
{n: "rare", p: 10, s: situations_rare},
{n: "uncommon", p: 30, s: situations_uncommon},
{n: "common", p: 50, s: situations_common}
];
for(let i = 0; i < 10000; i++){
generateOccurance()
}
function displaySituation(result){
//console.log(result)
}
function generateOccurance(){
let totalProbability = [];
let randomNumber = Math.random();
let sum = 0;
let i = 0;
occurances.forEach((occurance,index)=>{
sum += (occurance.p / 100.0);
totalProbability[index] = sum;
})
for(i = 0 ; i < totalProbability.length...