SimpleCxxLib
package#include "random.h"
Functions | |
Returns true with the probability indicated by p . | |
Returns a random integer in the range low to high , inclusive. | |
Returns a random real number in the half-open interval [low , high ). | |
Sets the internal random number seed to the specified value. |
int randomInteger(int low, int high);
low
to
high
, inclusive.
Usage:
int n = randomInteger(low, high);
double randomReal(double low, double high);
low
, high
). A half-open
interval includes the first endpoint but not the second, which
means that the result is always greater than or equal to
low
but strictly less than high
.
Usage:
double d = randomReal(low, high);
bool randomChance(double p);
true
with the probability indicated by p
.
The argument p
must be a floating-point number between
0 (never) and 1 (always). For example, calling
randomChance(.30)
returns true
30 percent
of the time.
Usage:
if (randomChance(p)) ...
void setRandomSeed(int seed);
Usage:
setRandomSeed(seed);