【发布时间】:2025-12-16 14:40:02
【问题描述】:
我正在学习使用 swift 和 Gameplaykit 生成随机数。在下面的代码中,是在我初始化 randomDist 时生成的数字,它只是在我调用 nextInt 时从已经生成的数字中给出一个样本,还是在我调用 nextInt() 时随机生成器是惰性生成的?
let rand = GKMersenneTwisterRandomSource() // the generator can be specified
let randomDist = GKRandomDistribution(randomSource: rand, lowestValue: 50, highestValue: 100)
randomDist.nextInt()
【问题讨论】:
标签: swift gameplay-kit