mercredi 18 novembre 2015

Configurable Chance

I have the following code:

double item;
item =  Math.random()*100;
if (item <= 10){
    print("A!")
} else if (item >= 10 && item <= 50){
    print("B!")
} else if (item >= 50 && item <= 90){
    print("C!")
} else if (item >= 90){
    print("D!")
}

How do i make it so that the user can have X amount of input, each with their own custom chance?

EDIT: To clarify a bit, I want to read from a YAML file in a format somewhat like this:

outcomes: item1: chance: 50 output: A etc




Aucun commentaire:

Enregistrer un commentaire