[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Getting randomic integers
- From: Rob Kendrick <rjek@...>
- Date: Sun, 17 Jan 2010 20:02:53 +0000
On Sun, 17 Jan 2010 20:59:41 +0100
Wolfgang Pupp <wolfgang.pupp@gmail.com> wrote:
> Btw., is there some decent, "resumable"- RNG for Lua around?
> What I want is essentially a "getrandomseed", which returns the
> current seed and can thus be used for resuming the generation of
> random numbers later, with perfectly predictable output.
You can do this with a cryptographic hash. For each "number" you want
out, hash together your seed and an index. Should you ever want the
same index again, just hash the seed and index again. Want the next
number in the sequence? Increase the index. Etc.
Should be easy to implement this in Lua using an off-the-shelf hash
library. (like lmd5).
B.
- References:
- Re: Getting randomic integers, Gé Weijers
- Re: Getting randomic integers, startx
- Re: Getting randomic integers, Majic
- Re: Getting randomic integers, startx
- Re: Getting randomic integers, Klaus Ripke
- Re: Getting randomic integers, Luiz Henrique de Figueiredo
- Re: Getting randomic integers, Klaus Ripke
- Re: Getting randomic integers, Rob Kendrick
- Re: Getting randomic integers, Erik Lindroos
- Re: Getting randomic integers, Klaus Ripke
- Re: Getting randomic integers, Wolfgang Pupp