Now you are using a GKShuffledDistribution with the same initializer as previous,once again the only thing that changes is how the distribution is handled.The results sidebar output will look something like this 4, 1, 2, 3, 5, 4, 2, 1, 3,5 (again, your numbers may vary).Notice how this result does not repeat a number until all the numbers have beenreturned. It's still possible to have two of the same number, side by side, at thebeginning and end of cycles as all numbers are available again at the end of thecylcle.The shuffled distribution becomes the most predictable of the distribution as youknow the last number of the cycle will always be the number that hasn't appearedyet.Randomization sourcesSo far, you've only used GameplayKit's default source, ARC4 random, but there aretwo other sources available:• Linear Congruential: The algorithm is faster than ARC4 but also considered tobe less random and more likely to follow a pattern. This source is recommendedwhen you need to generate results quickly.• Mersenne Twister: This is the slowest of the three but also the most random,when true unpredictability is important over speed this is the one to use.The primary tradeoff to consider when choosing a source is between randomnessand performance. To increase the randomness of a source, you have to performextra computations, which negatively impact performance.
đang được dịch, vui lòng đợi..
