DDNet documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
prng.h
Go to the documentation of this file.
1
#ifndef GAME_PRNG_H
2
#define GAME_PRNG_H
3
4
#include <cstdint>
5
6
class
CPrng
7
{
8
public
:
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
24
private
:
25
char
m_aDescription
[64];
26
27
bool
m_Seeded
;
28
uint64_t
m_State
;
29
uint64_t
m_Increment
;
30
};
31
32
#endif
// GAME_PRNG_H
CPrng::CPrng
CPrng()
Definition
prng.cpp:13
CPrng::Description
const char * Description() const
Definition
prng.cpp:18
CPrng::RandomBits
unsigned int RandomBits()
Definition
prng.cpp:44
CPrng::m_State
uint64_t m_State
Definition
prng.h:28
CPrng::Seed
void Seed(uint64_t aSeed[2])
Definition
prng.cpp:32
CPrng::m_aDescription
char m_aDescription[64]
Definition
prng.h:25
CPrng::m_Increment
uint64_t m_Increment
Definition
prng.h:29
CPrng::m_Seeded
bool m_Seeded
Definition
prng.h:27
src
game
prng.h
Generated by
1.18.0