TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Random.h File Reference
#include "Define.h"
#include <limits>
#include <random>
+ Include dependency graph for Random.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SFMTEngine
 
struct  Trinity::discrete_distribution_param< T >
 

Namespaces

 Trinity
 

Functions

TC_COMMON_API int32 irand (int32 min, int32 max)
 
TC_COMMON_API uint32 urand (uint32 min, uint32 max)
 
TC_COMMON_API uint32 urandms (uint32 min, uint32 max)
 
TC_COMMON_API uint32 rand32 ()
 
TC_COMMON_API float frand (float min, float max)
 
TC_COMMON_API double rand_norm ()
 
TC_COMMON_API double rand_chance ()
 
bool roll_chance_f (float chance)
 
bool roll_chance_i (int chance)
 

Function Documentation

TC_COMMON_API float frand ( float  min,
float  max 
)
59 {
60  ASSERT(max >= min);
61  return float(GetRng()->Random() * (max - min) + min);
62 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

TC_COMMON_API int32 irand ( int32  min,
int32  max 
)
40 {
41  ASSERT(max >= min);
42  return int32(GetRng()->IRandom(min, max));
43 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
int32_t int32
Definition: g3dmath.h:167
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TC_COMMON_API uint32 rand32 ( )
65 {
66  return GetRng()->BRandom();
67 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
uint32_t BRandom()
Definition: SFMT.h:240

+ Here is the call graph for this function:

TC_COMMON_API double rand_chance ( )
75 {
76  return GetRng()->Random() * 100.0;
77 }
double Random()
Definition: SFMT.h:227
static SFMTRand * GetRng()
Definition: Random.cpp:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TC_COMMON_API double rand_norm ( )
70 {
71  return GetRng()->Random();
72 }
double Random()
Definition: SFMT.h:227
static SFMTRand * GetRng()
Definition: Random.cpp:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool roll_chance_f ( float  chance)
inline
48 {
49  return chance > rand_chance();
50 }
TC_COMMON_API double rand_chance()
Definition: Random.cpp:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool roll_chance_i ( int  chance)
inline
54 {
55  return chance > irand(0, 99);
56 }
TC_COMMON_API int32 irand(int32 min, int32 max)
Definition: Random.cpp:39

+ Here is the call graph for this function:

TC_COMMON_API uint32 urand ( uint32  min,
uint32  max 
)
46 {
47  ASSERT(max >= min);
48  return GetRng()->URandom(min, max);
49 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define ASSERT
Definition: Errors.h:55
uint32_t URandom(uint32_t min, uint32_t max)
Definition: SFMT.h:208

+ Here is the call graph for this function:

TC_COMMON_API uint32 urandms ( uint32  min,
uint32  max 
)
52 {
53  ASSERT(max >= min);
54  ASSERT(INT_MAX / IN_MILLISECONDS >= max);
55  return GetRng()->URandom(min * IN_MILLISECONDS, max * IN_MILLISECONDS);
56 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Definition: Common.h:103
#define ASSERT
Definition: Errors.h:55
uint32_t URandom(uint32_t min, uint32_t max)
Definition: SFMT.h:208

+ Here is the call graph for this function:

+ Here is the caller graph for this function: