vendredi 24 novembre 2017

C++: Can I save a rand() generator to an object for asynchronous determinism?

I've searched around but struggled to find something that exactly fits my needs. I want to generate a series of random numbers with rand() after setting the seed with srand().

The catch is I need to do this asynchronously and other random sequences may be concurrently generated. I need to maintain the same deterministic sequence that would be generated all at once. Because rand() is global, I don't think there's any way to do this with rand().

The solution in my mind would be something that acts just like srand/rand but can be saved and passed as an object. e.g.

RandGenerator random(srand_seed) int r = random.get_random();

I don't need any of the "extra random" utils from C++11, but I'll use them if they somehow help me here. I just don't understand where to look.




Aucun commentaire:

Enregistrer un commentaire