*hap*, is Welsh for “random” or “chance”. :-) The functionality implemented by this package is divided into four different groups:

**random number generators**, deterministic pseudo-random algorithms;**random distributions**;**random adaptors**, such as shuffling or sampling objects;**traits**related to random number generation.

**random devices**, non-deterministic sources of randomness.

**Migration:**

To use hap.random instead of std.random it should suffice to:

- replace import std.random with import hap.random
- insert new before every instantiation of an RNG. For example, instead of auto rng = Random(unpredictableSeed) put instead, auto rng = new Random(unpredictableSeed).
- optionally, the functions randomCover, randomSample and randomShuffle may be replaced by cover, sample and shuffle; however, this is optional, not required.

**Note:**

Currently only one function is known to produce different behaviour to its std.random counterpart: hap.random.distribution.dice uses a different algorithm to std.random.dice.

**Warning:**

Bear in mind that non-reference-type RNGs used in conjunction with this package will almost certainly generate erroneous results. In particular this package should not be used together with std.random itself.

**License:**

Boost License 1.0.

**Authors:**

Andrei Alexandrescu, Chris Cain, Andrej Mitrović, Masahiro Nakagawa, Joseph Rushton Wakeling

**Source:**

hap/random/package.d