Shinya Kitaoka 810553
#pragma once
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
*/
Shinya Kitaoka 120a6e
class DVAPI TRandom {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TRandom(UINT seed = 0);
Shinya Kitaoka 120a6e
  ~TRandom();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! resets the pseudorandom engine to the first number of the sequence */
Shinya Kitaoka 120a6e
  void reset();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! set a new seed for the pseudorandom engine and reset the sequence */
Shinya Kitaoka 120a6e
  void setSeed(UINT seed);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! returns an unsigned integer number in the range [0, end[ */
Shinya Kitaoka 120a6e
  UINT getUInt(UINT end = c_maxuint);  // [0,end[
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! returns an integer number in the range [begin, end[ */
Shinya Kitaoka 120a6e
  int getInt(int begin, int end);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! returns a float number in the range [0, 1[ */
Shinya Kitaoka 120a6e
  float getFloat();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! returns a float number in the range [0, end[ */
Shinya Kitaoka 120a6e
  float getFloat(float end);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! returns a float number in the range [begin, end[ */
Shinya Kitaoka 120a6e
  float getFloat(float begin, float end);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! returns a random bool value */
Shinya Kitaoka 120a6e
  bool getBool();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! returns a double number in the range [0, 1[ */
Shinya Kitaoka 120a6e
  double getDouble();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  UINT seed;
Shinya Kitaoka 120a6e
  int idx1, idx2;
Shinya Kitaoka 120a6e
  UINT ran[56];
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  enum RANDOM_FLOAT_TYPE {
Shinya Kitaoka 120a6e
    RANDOM_FLOAT_TYPE_NONE,
Shinya Kitaoka 120a6e
    RANDOM_FLOAT_TYPE_1,
Shinya Kitaoka 120a6e
    RANDOM_FLOAT_TYPE_2,
Shinya Kitaoka 120a6e
    RANDOM_FLOAT_TYPE_HOW_MANY
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static RANDOM_FLOAT_TYPE RandomFloatType;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  inline UINT getNextUINT();
Shinya Kitaoka 120a6e
  inline void setRandomFloatType();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TRANDOM_INCLUDED