Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to generate the same random sequence from a given seed in Delphi

I am wanting to generate the same random sequence (of numbers or characters) based on a given "seed" value.

Using the standard Randomize function does not seem to have such an option.

For example in C# you can initialize the Random function with a seed value (Random seed c#).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I achieve something similar in Delphi, or can you point me to an open source library that can do this.

>Solution :

You only need to assign a particular value to the RandSeed global variable.

Actually, I’m almost surprised you asked, because you clearly know of the Randomize function, the documentation for which states the following:

The random number generator should be initialized by making a call to Randomize, or by assigning a value to RandSeed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading