upsilon/linux/random.py

11 lines
349 B
Python
Raw Permalink Normal View History

2024-03-14 06:02:47 -04:00
class RandomGenerator:
# XorShift
def __init__(self, seed=2463534242):
self.seed = seed
def __call__(self):
self.seed = self.seed ^ ((self.seed << 13) & 0xFFFFFFFF)
self.seed = self.seed ^ ((self.seed >> 17) & 0xFFFFFFFF)
self.seed = self.seed ^ ((self.seed << 5) & 0xFFFFFFFF)
return self.seed