Last active
January 27, 2020 20:50
-
-
Save laevandus/9b6cbcebfbf521f5946742bf5e53ec28 to your computer and use it in GitHub Desktop.
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
struct SeededRandomNumberGenerator: RandomNumberGenerator { | |
init(seed: Int) { | |
srand48(seed) | |
} | |
func next() -> UInt64 { | |
return UInt64(drand48() * Double(UInt64.max)) | |
} | |
} | |
var seededGenerator = SeededRandomNumberGenerator(seed: 5) | |
let random = Int.random(in: -5...5, using: &seededGenerator) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment