Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- class RNG
- {
- public:
- uint32_t seed;
- uint16_t advance();
- }
- uint16_t RNG::advance()
- {
- // set seed to last 32 bits of (seed * 0x41C64E6D + 0x6073)
- seed = (seed * 0x41C64E6D + 0x6073) & ((1u << 32) - 1);
- // return first 16 bits
- return (seed & ((1u << 16) - 1));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement