#ifndef NALL_RANDOM_HPP #define NALL_RANDOM_HPP //pseudo-random number generator //very low-quality, but very fast (based on CRC32 polynomial) namespace nall { inline unsigned prng() { static unsigned n = 0; return n = (n >> 1) ^ (((n & 1) - 1) & 0xedb88320); } struct random_lfsr { inline void seed(unsigned seed__) { seed_ = seed__; } inline unsigned operator()() { return seed_ = (seed_ >> 1) ^ (((seed_ & 1) - 1) & 0xedb88320); } random_lfsr() : seed_(0) { } private: unsigned seed_; }; } #endif