Is continuously seeding a random number generator performance intensive?
monarch_dodra
monarchdodra at gmail.com
Thu Jan 2 14:01:00 PST 2014
On Thursday, 2 January 2014 at 20:38:10 UTC, Jeroen Bollen wrote:
> D provides a set of Random Number Generators in std.random. I
> am writing an application which would create a 2D map of noise.
> To do this though, I'll have to calculate the same random
> numbers over and over again. (I cannot store them, that'd take
> a horrible amount of RAM. )
AFAIK, the costliest part of seeding a generator is generating
the "random seed". After that, once you have the seed, it
shouldn't be too expensive. That said, it depends on each
generator of course. In any case, performance wise, it shouldn't
be too expensive (if you use the same seed).
That said, it sounds like what you want to do though is to simply
"save" the range. PRNG's have the "save" primitive you can use.
Just use that.
> Is it good to re-seed a generator for every coordinate, will
> this be performance intensive? Is there maybe way to easily
> implement Generator.at(uint x) in D?
*This* comment is confusing me. What do you mean by "re-seed"?
You mean a random seed? Once seeded, you shouldn't have to
re-seed a PRNG: It'll generate random numbers forever. Or do you
mean "re-seed" in the sense "reset"? Because if you do that, then
you'll have the same numbers for each coordinates...?
More information about the Digitalmars-d-learn
mailing list