jeudi 22 juin 2017

Probability and random numbers

I am just starting with C++ and am creating a simple text-based adventure. I am trying to figure out how to have probability based events. For example a 50% chance that when you open box there will be a sword and a 50% chance it will be a knife. I know how to make a random number generator, but I don't know how to associate that number with something. I created a variation of what I want but it requires the user to input the random number. I am wondering how to base the if statement on whether or not the random number was greater or less than 50, not if the number the user put in was greater or less than 50.




Aucun commentaire:

Enregistrer un commentaire