krz/daybyday

iOS learning games for young children: days, months, seasons, numbers, letters, animals and more. education ios kids swift https://krz.sh/apps/daybyday/

DayByDayTests/SeededGenerator.swift

062549ad26607ce9e973ed2a9a7ef6f853885f83
daybyday/DayByDayTests/SeededGenerator.swift history · blame · raw

14 lines · 424 bytes

1 symbol in this file
  • next function, line 7
 1/// Deterministic SplitMix64 generator for tests.
 2nonisolated struct SeededGenerator: RandomNumberGenerator {
 3    private var state: UInt64
 4
 5    init(seed: UInt64) { state = seed }
 6
 7    mutating func next() -> UInt64 {
 8        state &+= 0x9E37_79B9_7F4A_7C15
 9        var z = state
10        z = (z ^ (z >> 30)) &* 0xBF58_476D_1CE4_E5B9
11        z = (z ^ (z >> 27)) &* 0x94D0_49BB_1331_11EB
12        return z ^ (z >> 31)
13    }
14}