The random number generator is seeded at program startup with a random value. This ensures that each program generates a different sequence of random numbers. To generate a repeatable sequence, use rand_seed() to start the sequence. seed and index start it, and each successive value increments index. This means that the
nth random number of the sequence can be directly generated by passing index +
n to rand_seed().
- Note:
- This is more random, but slower, than C's rand() function. To use C's rand() instead, import std.c.stdlib.