-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrandom.h
54 lines (44 loc) · 1.51 KB
/
random.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef _random_h
#define _random_h
/// This class provides several functions for generating pseud-random numbers.
///
class Random {
public:
/// \brief
///
/// Initialize the randomizer.
///
Random();
/// \brief
///
/// Generates a random integer number greater than or equal to low and less than high.
/// \param low int - lower bound for range (inclusive).
/// \param high int - upper bound for range (exclusive).
/// \return int - A random integer number greater than or equal to low and less than high.
///
int randomInteger(int low, int high);
/// \brief
/// Generates a random real number greater than or equal to low and less than high.
///
/// \param low double - lower bound for range (inclusive).
/// \param high double - upper bound for range (exclusive).
/// \return double - A random real number greater than or equal to low and less than high.
///
double randomReal(double low, double high);
/// \brief
/// Generates a true false outcome based on the probability p.
/// Calling randomChance(0.30) returns true 30% of the time.
///
/// \param p double - Value between 0 (never) and 1 (always).
/// \return bool - true or false based on p.
///
bool randomChance(double p);
private:
/// \brief
///
/// Initializes teh random-number generator so that its results are unpredictable. If this function is
/// not called the other functions will return the same values on each run.
///
void randomize();
};
#endif // _random_h