tcod.random - Random Number Generators¶
Usually it’s recommend to the Python’s standard library random module instead of this one.
However, you will need to use these generators to get deterministic results
from the Noise
and BSP
classes.
-
class
tcod.random.
Random
(algorithm: int = 0, seed: Optional[Hashable] = None)[source]¶ The libtcod random number generator.
algorithm defaults to Mersenne Twister, it can be one of:
- tcod.random.MERSENNE_TWISTER
- tcod.random.MULTIPLY_WITH_CARRY
seed is a 32-bit number or any Python hashable object like a string. Using the same seed will cause the generator to return deterministic values. The default seed of None will generate a random seed instead.
-
random_c
¶ A cffi pointer to a TCOD_random_t object.
Type: CData
Changed in version 9.1: Added tcod.random.MULTIPLY_WITH_CARRY constant. algorithm parameter now defaults to tcod.random.MERSENNE_TWISTER.
-
guass
(mu: float, sigma: float) → float[source]¶ Return a random number using Gaussian distribution.
Parameters: Returns: A random float.
Return type:
-
inverse_guass
(mu: float, sigma: float) → float[source]¶ Return a random Gaussian number using the Box-Muller transform.
Parameters: Returns: A random float.
Return type: