World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл lfg.h

См. исходные тексты.

Классы

struct  AVLFG
 

Определения типов

typedef struct AVLFG AVLFG
 

Функции

void av_lfg_init (AVLFG *c, unsigned int seed)
 
int av_lfg_init_from_data (AVLFG *c, const uint8_t *data, unsigned int length)
 
static unsigned int av_lfg_get (AVLFG *c)
 
static unsigned int av_mlfg_get (AVLFG *c)
 
void av_bmg_get (AVLFG *lfg, double out[2])
 

Типы

◆ AVLFG

typedef struct AVLFG AVLFG

Context structure for the Lagged Fibonacci PRNG. The exact layout, types and content of this struct may change and should not be accessed directly. Only its sizeof() is guranteed to stay the same to allow easy instanciation.

Функции

◆ av_lfg_init()

void av_lfg_init ( AVLFG c,
unsigned int  seed 
)

◆ av_lfg_init_from_data()

int av_lfg_init_from_data ( AVLFG c,
const uint8_t data,
unsigned int  length 
)

Seed the state of the ALFG using binary data.

Return value: 0 on success, negative value (AVERROR) on failure.

◆ av_lfg_get()

static unsigned int av_lfg_get ( AVLFG c)
inlinestatic

Get the next random unsigned 32-bit number using an ALFG.

Please also consider a simple LCG like state= state*1664525+1013904223, it may be good enough and faster for your specific use case.

См. определение в файле lfg.h строка 53

53  {
54  unsigned a = c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
55  c->index += 1U;
56  return a;
57 }

◆ av_mlfg_get()

static unsigned int av_mlfg_get ( AVLFG c)
inlinestatic

Get the next random unsigned 32-bit number using a MLFG.

Please also consider av_lfg_get() above, it is faster.

См. определение в файле lfg.h строка 64

64  {
65  unsigned int a= c->state[(c->index-55) & 63];
66  unsigned int b= c->state[(c->index-24) & 63];
67  a = c->state[c->index & 63] = 2*a*b+a+b;
68  c->index += 1U;
69  return a;
70 }

◆ av_bmg_get()

void av_bmg_get ( AVLFG lfg,
double  out[2] 
)

Get the next two numbers generated by a Box-Muller Gaussian generator using the random numbers issued by lfg.

Аргументы
outarray where the two generated numbers are placed
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1112
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11096
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1112