mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 13:11:33 +00:00
use arc4random to seed non-csprng, fleshes out random subsystem
This commit is contained in:
@ -17,8 +17,12 @@ public class Arc4Random: RandomProvider {
|
||||
arc4random()
|
||||
}
|
||||
|
||||
public func next(in bound: Range<Int>) -> Int {
|
||||
assert(bound.upperBound <= Self.max)
|
||||
return bound.lowerBound + Int(arc4random_uniform(UInt32(bound.upperBound)))
|
||||
public func next(in bound: Int) -> Int {
|
||||
assert(bound <= Self.max)
|
||||
return Int(arc4random_uniform(UInt32(bound)))
|
||||
}
|
||||
|
||||
public func next(in range: Range<Int>) -> Int {
|
||||
return range.lowerBound + next(in: range.upperBound - range.lowerBound)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user