PCG 随机数生成器
PCG random 生成器,用于 Swift 语言。
安装
Swift 包管理器
dependencies: [
.package(url: "https://github.com/paiv/swift-pcg-random.git", .upToNextMajor(from: "1.0.0"))
]
CocoaPods
pod 'PcgRandom', '~> 1.0'
使用方法
import PcgRandom
var pcg = Pcg64Random(seed: .random(in: .min ... .max))
let dice = Int.random(in: 1...20, using: &pcg)
print(dice)