Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
PcgRandom Class Reference

#include <noise.h>

Public Member Functions

 PcgRandom (u64 state=0x853c49e6748fea9bULL, u64 seq=0xda3e39cb94b95bdbULL)
 
void seed (u64 state, u64 seq=0xda3e39cb94b95bdbULL)
 
u32 next ()
 
u32 range (u32 bound)
 
s32 range (s32 min, s32 max)
 
void bytes (void *out, size_t len)
 
s32 randNormalDist (s32 min, s32 max, int num_trials=6)
 
void getState (u64 state[2]) const
 
void setState (const u64 state[2])
 

Static Public Attributes

static const s32 RANDOM_MIN = -0x7fffffff - 1
 
static const s32 RANDOM_MAX = 0x7fffffff
 
static const u32 RANDOM_RANGE = 0xffffffff
 

Private Attributes

u64 m_state
 
u64 m_inc
 

Constructor & Destructor Documentation

◆ PcgRandom()

PcgRandom::PcgRandom ( u64 state = 0x853c49e6748fea9bULL,
u64 seq = 0xda3e39cb94b95bdbULL )

References seed().

+ Here is the call graph for this function:

Member Function Documentation

◆ bytes()

void PcgRandom::bytes ( void * out,
size_t len )

References next().

Referenced by myrand_bytes(), and TestRandom::testPcgRandomBytes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getState()

void PcgRandom::getState ( u64 state[2]) const

References m_inc, and m_state.

Referenced by LuaPcgRandom::l_get_state(), and TestRandom::testPcgRandom().

+ Here is the caller graph for this function:

◆ next()

u32 PcgRandom::next ( )

References m_inc, and m_state.

Referenced by bytes(), OreVein::generate(), httpfetch_caller_alloc_secure(), myrand(), myrand_float(), range(), seed(), TestRandom::testPcgRandom(), TestRandom::testPcgRandomRange(), and TestMapBlock::testSaveLoad().

+ Here is the caller graph for this function:

◆ randNormalDist()

s32 PcgRandom::randNormalDist ( s32 min,
s32 max,
int num_trials = 6 )

References myround(), and range().

Referenced by LuaPcgRandom::l_rand_normal_dist(), and TestRandom::testPcgRandomNormalDist().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ range() [1/2]

s32 PcgRandom::range ( s32 min,
s32 max )

References range().

+ Here is the call graph for this function:

◆ range() [2/2]

u32 PcgRandom::range ( u32 bound)

References next().

Referenced by BiomeGenOriginal::calcBiomeFromNoise(), DecoSchematic::generate(), DecoSimple::generate(), OreBlob::generate(), OrePuff::generate(), OreScatter::generate(), OreSheet::generate(), OreStratum::generate(), LuaPcgRandom::l_next(), myrand_range(), Decoration::placeDeco(), randNormalDist(), range(), TestRandom::testPcgRandomRange(), and Sky::updateStars().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ seed()

void PcgRandom::seed ( u64 state,
u64 seq = 0xda3e39cb94b95bdbULL )

References m_inc, m_state, and next().

Referenced by PcgRandom(), and mysrand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setState()

void PcgRandom::setState ( const u64 state[2])

References m_inc, and m_state.

Referenced by LuaPcgRandom::l_set_state(), and TestRandom::testPcgRandom().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_inc

u64 PcgRandom::m_inc
private

Referenced by getState(), next(), seed(), and setState().

◆ m_state

u64 PcgRandom::m_state
private

Referenced by getState(), next(), seed(), and setState().

◆ RANDOM_MAX

const s32 PcgRandom::RANDOM_MAX = 0x7fffffff
static

◆ RANDOM_MIN

const s32 PcgRandom::RANDOM_MIN = -0x7fffffff - 1
static

◆ RANDOM_RANGE

const u32 PcgRandom::RANDOM_RANGE = 0xffffffff
static

Referenced by OreVein::generate().


The documentation for this class was generated from the following files: