|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TRANDOM_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TRANDOM_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZCORE_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Generates a pseudorandom sequence
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TRandom
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TRandom(UINT seed = 0);
|
|
Toshihiro Shimizu |
890ddd |
~TRandom();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! resets the pseudorandom engine to the first number of the sequence */
|
|
Toshihiro Shimizu |
890ddd |
void reset();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! set a new seed for the pseudorandom engine and reset the sequence */
|
|
Toshihiro Shimizu |
890ddd |
void setSeed(UINT seed);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! returns an unsigned integer number in the range [0, end[ */
|
|
Toshihiro Shimizu |
890ddd |
UINT getUInt(UINT end = c_maxuint); // [0,end[
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! returns an integer number in the range [begin, end[ */
|
|
Toshihiro Shimizu |
890ddd |
int getInt(int begin, int end);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! returns a float number in the range [0, 1[ */
|
|
Toshihiro Shimizu |
890ddd |
float getFloat();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! returns a float number in the range [0, end[ */
|
|
Toshihiro Shimizu |
890ddd |
float getFloat(float end);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! returns a float number in the range [begin, end[ */
|
|
Toshihiro Shimizu |
890ddd |
float getFloat(float begin, float end);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! returns a random bool value */
|
|
Toshihiro Shimizu |
890ddd |
bool getBool();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! returns a double number in the range [0, 1[ */
|
|
Toshihiro Shimizu |
890ddd |
double getDouble();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
UINT seed;
|
|
Toshihiro Shimizu |
890ddd |
int idx1, idx2;
|
|
Toshihiro Shimizu |
890ddd |
UINT ran[56];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum RANDOM_FLOAT_TYPE {
|
|
Toshihiro Shimizu |
890ddd |
RANDOM_FLOAT_TYPE_NONE,
|
|
Toshihiro Shimizu |
890ddd |
RANDOM_FLOAT_TYPE_1,
|
|
Toshihiro Shimizu |
890ddd |
RANDOM_FLOAT_TYPE_2,
|
|
Toshihiro Shimizu |
890ddd |
RANDOM_FLOAT_TYPE_HOW_MANY
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static RANDOM_FLOAT_TYPE RandomFloatType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline UINT getNextUINT();
|
|
Toshihiro Shimizu |
890ddd |
inline void setRandomFloatType();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //TRANDOM_INCLUDED
|