A randomizer object to be used when the strategist randomly selects a move.
- iOS 9.1+
- macOS 10.11.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
A strategist class uses this random source when you call the
best method. Different strategist classes use randomization in different ways:
A deterministic strategy, such as that of the
GKMinmaxclass, can reach states where multiple moves are rated the most desirable. In such cases, the strategist can randomly choose from among the best possible moves, making the behavior of a computer-controlled player appear more natural and unpredictable.
If this property is set to
nil(the default), the
GKMinmaxclass method does not randomize—that is, when repeatedly presented with the same set of equally-optimal moves, the
bestmethod always makes the same choice.
Move For Active Player()
A probabilistic strategy, such as that of the
GKMonteclass, requires a random source in order to randomly explore the set of possible moves.
A randomizer is any object that implements the
GKRandom protocol, such as the
GKRandom classes and their subclasses. Choosing a separate randomizer instance from that used by other systems in your game ensures that the randomization of moves is independent; that is, the strategist's selection of moves does not depend on your game’s other uses of randomization APIs. You can also use randomizer classes to reproduce a specific sequence of random actions for debugging, and to fine-tune the randomization behavior.