Created
May 17, 2020 22:23
-
-
Save nicklockwood/8bf5d7e0c5fef69cab62c57239a90765 to your computer and use it in GitHub Desktop.
Working RNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private let multiplier: UInt64 = 6364136223846793005 | |
private let increment: UInt64 = 1442695040888963407 | |
public struct RNG: RandomNumberGenerator { | |
private var seed: UInt64 = 0 | |
public init(seed: UInt64) { | |
self.seed = seed | |
} | |
public mutating func next() -> UInt64 { | |
seed = seed &* multiplier &+ increment | |
return seed | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment