vendredi 10 février 2023

How can I create pseudo-random numbers depending on multiple integer parameters?

My overall goal is to create a round-based game. So, I need some seemingly randomly generated numbers, examply in fights - but not only, there are some different occasions. Anyway, I want those numbers to be reliably the same if certain parameters are the same. Those parameters will be an integer seed - it will take the value of a generalRandomSeed, changing every round; but I need more parameters, like IDs of attacker and defender. I would be very convenient to call this function with the parameters (maybe all combined in a vector) like getRandom(generalRandomSeed,id1,id2). So, in the end I am hoping for a function that takes one or more ints as parameters (ideally, a vector), returning one single integer: int getRandom(std::vector parameters);

I canot quite figure out how I could solve that problem; if it was only about one parameter, I might just create a new mt19937 every time with my seed generalRandomSeed.




Aucun commentaire:

Enregistrer un commentaire