Computer Science Canada Random Next and Seed |
Author: | Prince Pwn [ Sat Jan 16, 2010 1:34 pm ] | ||
Post subject: | Random Next and Seed | ||
What is it you are trying to achieve? I wish to make a seed for my random generation for an encryption algorithm. I Need the same sequence of letters to stay every time I execute the program. What is the problem you are having? Not too sure how the different Rand methods work together. Describe what you have tried to solve this problem Scoured the Turing Help file through Rand.Set, nat, and Rand.Seed. Found it pretty confusing. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using Version 4.1 |
Author: | TerranceN [ Sat Jan 16, 2010 2:04 pm ] | ||||
Post subject: | RE:Random Next and Seed | ||||
Use Rand.Set. This sets what the pseudo-random generator is using to determine values. Since the generator is pseudo-random having the same seed every time will yeild the same results. For example after adding Rand.Set(1) to your program:
It now always outputs
|
Author: | Prince Pwn [ Sat Jan 16, 2010 2:09 pm ] |
Post subject: | RE:Random Next and Seed |
Ah, I see. And changing the 'key' or 'seed' will output different values but if I use the same key it stays the same. Thanks ![]() But if I were to say re-code in C++ or Java, could I use the same seed as in Turing and get the same results? |
Author: | TerranceN [ Sat Jan 16, 2010 2:23 pm ] |
Post subject: | RE:Random Next and Seed |
It depends on how they generate pseudo-random numbers. If it is the same as Turing, then yes. But I have no idea how Turing generates it (and since it's closed source, only holtsoft knows), so you would have to test it in order to figure it out. |