[Python-ideas] Python's Source of Randomness and the random.py module Redux
Paul Moore
p.f.moore at gmail.com
Fri Sep 11 12:03:42 CEST 2015
On 11 September 2015 at 10:52, Nathaniel Smith <njs at pobox.com> wrote:
> You don't really want to use the full 4992 byte state for a "map seed"
> application anyway (type 'random.getstate()' in a REPL and watch your
> terminal scroll down multiple pages...). No game actually uses map
> seeds that look anything like that. I'm 99% sure that real
> applications in this category are actually using logic like:
>
> if <user supplied a "seed">:
> seed = user_seed()
> else:
> # use some RNG that was seeded with real entropy
> seed = random_short_printable_string()
> r = random.Random(seed)
> # now use 'r' to generate the map
Yeah, good point. As I say, I don't actually *use* this in the example
program I'm thinking of, I just know it's a feature I need to add in
due course. So when I do, I'll have to look into how to best implement
it. (And I'll probably nick the approach you show above, thanks ;-))
Paul
More information about the Python-ideas
mailing list