This commit is contained in:
2024-11-03 17:48:59 -06:00
parent 583b9234fd
commit 3b1a207b3f
10 changed files with 262 additions and 255 deletions

View File

@@ -0,0 +1,21 @@
struct SplitMix64 : RandomNumberGenerator {
public typealias State = UInt64
public private(set) var state: State
init(state: UInt64) {
self.state = state
}
public mutating func next() -> UInt64 {
state &+= 0x9E3779B97F4A7C15
var z = state
z = (z ^ (z >> 30)) &* 0xBF58476D1CE4E5B9
z = (z ^ (z >> 27)) &* 0x94D049BB133111EB
return z ^ (z >> 31)
}
public mutating func nextDouble() -> Double {
Double(next() >> 11) * 0x1.0p-53
}
}