Jump to content
Registration disabled at the moment Read more... ×
RaelB

Looking for thread-safe repeatable random sequence generator

Recommended Posts

I'm wanting to generate a repeatable random number/character sequence based on a given seed value. Using the in built Randomize function with global RandSeed can do this, but is not thread-safe. Any recommendation for open source/light weight solution?

Thanks

Share this post


Link to post

It is utterly trivial to make such a thing using the exact same code as found in Random. You make a record that contains a seed and you add a method that uses that seed to generate the next sample, and then update the seed. 

 

If you have specific requirements for the properties of the PRNG then you may find the LCG used by Random doesn't meet them. In which case you'd need to decide what your requirements are. 

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×