Skip to content

Instantly share code, notes, and snippets.

@nicklockwood
Created May 17, 2020 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicklockwood/8bf5d7e0c5fef69cab62c57239a90765 to your computer and use it in GitHub Desktop.
Save nicklockwood/8bf5d7e0c5fef69cab62c57239a90765 to your computer and use it in GitHub Desktop.
Working RNG
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