Blockland Forums > Modification Help
getRandom returning different results on mac and pc
<< < (11/11)
Slicks555:

--- Quote from: Port on May 20, 2012, 01:36:59 PM ---For one example of how non-random values can be useful, research Minecraft's world generation.

--- End quote ---
Well, I mean, yeah. That's why I said "I get that sometimes you want to be able to re-generate the same values" but I doubt that this guy needs seeded terrain generation that you can duplicate on Windows and Mac using the same seed.
Destiny/Zack0Wack0:

--- Quote from: Ipquarx on May 19, 2012, 01:59:27 PM ---The problem here is that inside a function, there is say, the following code:

--- Code: ---function blah()
{

setRandomSeed(1231410857510857584752610452674907490747475251113186867577116104117842712211751241120756767676774877366);

for(%a = 0; %a < 50; %a++)
{
echo(getRandom(0, 100));
}
}

--- End code ---
Try that on mac and pc, it will return different results.
Why?
How can I fix that?


--- End quote ---
Try doing setRandomSeed inside of the for loop (ie. directly before each getRandom call). If that doesn't work, use a linear-congruential generator, it's the fastest RNG (especially in Torque) and it works fine for everything but cryptography. I've used it for terrain generation before.

EDIT: To clarify, yes I completely understand how seeds work, but there is a (tiny) chance that setRandomSeed in fact sets what previous seeded values to use, and doesn't actually re-seed the RNG. It could be that the seed is being changed in the background before the getRandom call. Again unlikely, just making hopeful guesses so you don't have to result to your own TorqueScript (yuck) implementation of an RNG.
Navigation
Message Index
Previous page

Go to full version