DDraceNetwork Docs
prng.h
Go to the documentation of this file.
1#ifndef GAME_PRNG_H
2#define GAME_PRNG_H
3
4#include <cstdint>
5
6class CPrng
7{
8public:
9 // Creates an unseeded instance.
10 CPrng();
11
12 // The name of the random number generator including the current seed.
13 const char *Description() const;
14
15 // Seeds the random number generator with the given integer. The random
16 // sequence obtained by calling `RandomBits()` repeatedly is guaranteed
17 // to be the same for the same seed.
18 void Seed(uint64_t aSeed[2]);
19
20 // Generates 32 random bits. `Seed()` must be called before calling
21 // this function.
22 unsigned int RandomBits();
23
24private:
26
28 uint64_t m_State;
29 uint64_t m_Increment;
30};
31
32#endif // GAME_PRNG_H
Definition: prng.h:7
CPrng()
Definition: prng.cpp:12
const char * Description() const
Definition: prng.cpp:17
unsigned int RandomBits()
Definition: prng.cpp:43
uint64_t m_State
Definition: prng.h:28
void Seed(uint64_t aSeed[2])
Definition: prng.cpp:31
char m_aDescription[64]
Definition: prng.h:25
uint64_t m_Increment
Definition: prng.h:29
bool m_Seeded
Definition: prng.h:27