vendredi 15 décembre 2017

Random Values from a variable set of entries in a vector

i have a problem which is the following:

i have for example 4 objects. One object is randomly selected to do a certain action. E.g. if object 1 does an action, the other 3 objects do nothing.

So, i have a vector of these objects.

vector{object1,object2, object3, object4}

In the beginning, i can easily randomly select one object with vector[random].

And here comes the problem: An object can also "die" meaning the object should not be part of the random-step anymore.

For example, if object2 dies, if want to random between 1,3,4 and let the 2 out.

Is this possible somehow? (using C++)

Thanks!




Aucun commentaire:

Enregistrer un commentaire