The ANL library includes a number of random number generators based on generators designed by George Marsaglia. The generators are:
LCG: Simple Linear Congruential Generator
Xorshift: Xor Shift generator
KISS: Keep It Simple, Stupid
MWC256: Multiply-with-carry 256
CMWC4096: Complementary-multiply-with-carry 4096
All of the random generators share a common interface:
class CBasePRNG { public: virtual unsigned int get(); virtual void setSeed(unsigned int s); void setSeedTime(); unsigned int getTarget(unsigned int t); unsigned int getRange(unsigned int low, unsigned int high); double get01(); };
get(): Obtains a value in the range of (0,MAX_UNSIGNED_INT).
getTarget(): Obtains a value in the range of (0,target).
getRange(): Obtains a value in the range of (low,high).
get01(): Obtains a value in the range of (0,1).
setSeed(): Seeds the RNG.
setSeedTime(): Seeds the RNG from the system time.
#include#include "anl.h" int main() { anl.CMWC4096 rng; rng.setSeed(1234); std::cout << rng.get() << std::endl; std::cout << rng.getTarget(1000) << std::endl; std::cout << rng.getRange(1,6) << std::endl; std::cout << rng.get01() << std::endl; return 1; } Expected output: 1394590422 614 6 0.66388264919256
Random generators are used at various places throughout the noise library, to seed various values and transformations.