Random
The random module contains utility classes and functions that might be useful for general purpose randomization.
SeedStore
¶
Utility class for generating PRNG seeds based on a single root seed.
A SeedStore object can also be used like an iterator to generate multiple seeds.
Examples:
store = SeedStore(1337)
first = next(store)
print(f"First seed {first}")
for i,s in enumerate(store, 0):
if i >= 10:
break
print(s)
__init__(self, mother_seed)
special
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mother_seed |
int |
The root seed from which all other seeds are generated from |
required |
Source code in generator/random.py
def __init__(self, mother_seed: int):
"""
Args:
mother_seed: The root seed from which all other seeds are generated from
"""
self.mother_seed = mother_seed
self._random = Random(mother_seed)
next(self)
¶
Creates the next PRNG seed from the store
Returns:
Type | Description |
---|---|
int |
A random int seed |
Source code in generator/random.py
def next(self) -> int:
"""Creates the next PRNG seed from the store
Returns:
A random int seed
"""
return self.__next__()