7. Pseudorandom number generator
This toolkit is an implementation of two fast and high quality pseudorandom number generators:
* a Mersenne twister generator,
* a Complementary-Multiply-With-Carry generator.
CMWC is faster than MT (see table below) and has a much better period (1039460 vs. 106001). It is the default algo since libtcod 1.5.0.
Relative performances in two independent tests (lower is better) :
Algorithm | Numbers generated | Perf (1) | Perf (2) |
---|---|---|---|
MT | integer | 62 | 50 |
MT | float | 54 | 45 |
CMWC | integer | 21 | 34 |
CMWC | float | 32 | 27 |
For python users:
Python already has great builtin random generators. But some parts of the Doryen library (noise, heightmap, ...) uses RNG as parameters. If you intend to use those functions, you must provide a RNG created with the library.
For C# users:
.NET already has great builtin random generators. But some parts of the Doryen library (noise, heightmap, ...) uses RNG as parameters. If you intend to use those functions, you must provide a RNG created with the library.