#include "random.h" ... Random r; r.srand(1); // generally unnecessary, seeds generator like stdlib.h's srand() r.rand(); // returns a random number a la stdlib.h's rand() r.get(); // ditto r.get(16); // returns 1 of 16 possible random numbers from 0 to 15 inclusive r.get(5,2); // returns 1 of 3 possible random numbers from 2 to 4 inclusive r.get(1.0f); // returns 1 of "Random::s_rand_max+1" floats, 0 <= value <1 r.get(1.0f,0.5f); // as above, but limits the result to 0.5 <= value <1 Random::s_rand_max; // similar to stdlib.h's RAND_MAX ...
#include <random.h>

Public Member Functions |
|
| UtilExport | Random () |
| UtilExport void | srand (unsigned int seed=1) |
| UtilExport int | rand () |
| int | get (int max_exclusive=s_rand_max+1, int min_inclusive=0) |
| float | getf (float max_exclusive=1.0f, float min_inclusive=0.0f) |
Static Public Attributes |
|
| static UtilExport const int | s_rand_max |
| UtilExport Random | ( | ) |
| UtilExport void srand | ( | unsigned int | seed = 1 |
) |
| UtilExport int rand | ( | ) |
| int get | ( | int | max_exclusive = s_rand_max+1, |
| int | min_inclusive =
0 |
||
| ) | [inline] |
{
return (this->rand() % (max_exclusive - min_inclusive) + min_inclusive);
}
| float getf | ( | float | max_exclusive =
1.0f, |
| float | min_inclusive =
0.0f |
||
| ) | [inline] |
{
return (this->rand() / (s_rand_max+1.0f) * (max_exclusive - min_inclusive) + min_inclusive);
}
UtilExport const int s_rand_max
[static] |