Unit CastleRandom

Description

Custom random number generator (TCastleRandom).

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TCastleRandom Custom, fast random number generator.

Functions and Procedures

function StringToHash(const InputString: AnsiString; const Seed: LongWord=0): LongWord;
function Rand: TCastleRandom;
function Rnd: single; overload; deprecated 'use Rand.Random';
function Rnd(N: LongInt): LongInt; overload; deprecated 'use Rand.Random';

Description

Functions and Procedures

function StringToHash(const InputString: AnsiString; const Seed: LongWord=0): LongWord;

Implementation of MurMur2 hash algorithm to make a cryptographic-unsafe but highly uniform 32bit hash from a given string very quickly. It may be used for better initialization of user defined random seeds (e.g. "My New World" sounds much better than 6592202398) or for better sorting/searching of strings. Warning: the hash is deterministic, but the result may be different depending on CPU architecture or endianness (test required).

Parameters
InputString
The input string
Seed
Optional parameter enabling initialization of the algorithm seed different from default
Returns

Unsigned 32-bit integer

function Rand: TCastleRandom;

Single random instance.

function Rnd: single; overload; deprecated 'use Rand.Random';

Warning: this symbol is deprecated: use Rand.Random

 
function Rnd(N: LongInt): LongInt; overload; deprecated 'use Rand.Random';

Warning: this symbol is deprecated: use Rand.Random

 

Generated by PasDoc 0.16.0.