auto x = dice(0.5, 0.5); // x is 0 or 1 in equal proportions auto y = dice(50, 50); // y is 0 or 1 in equal proportions auto z = dice(70, 20, 10); // z is 0 70% of the time, 1 20% of the time, // and 2 10% of the time
The range counterpart of dice is the DiscreteDistribution class.
Note: given an identically-seeded RNG as input, hap.random.distribution._dice will produce different values to std.random._dice.
Rolls a random die with relative probabilities stored in proportions. Returns the index in proportions that was chosen.