1234567891011121314151617181920212223242526 |
- #include <chrono>
- #include "common/utils/Random.h"
- Random::Random() : seed(std::chrono::steady_clock::now().time_since_epoch().count()) {
- }
- Random::Random(u64 seed) : seed(seed) {
- }
- u32 Random::next() {
- return nextSeed() >> 24;
- }
- u32 Random::next(uint bound) {
- return next() % bound;
- }
- float Random::nextFloat() {
- return next() * (1.0f / (0xFFFFFF + 1.0f));
- }
- u64 Random::nextSeed() {
- seed = (seed * 0x5DEECE66DL + 0xBL) & 0xFFFFFFFFFFFF;
- return seed;
- }
|