---
title: GKARC4RandomSource
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gkarc4randomsource
---

# GKARC4RandomSource

A basic random number generator implementing the ARC4 algorithm, which is suitable for most gameplay mechanics.

## Declaration

```swift
class GKARC4RandomSource
```

## Overview

Overview important: The randomization services provided in GameplayKit are suitable for reliably creating deterministic, pseudorandom gameplay mechanics, but are not cryptographically robust. For cryptography, obfuscation, or cipher uses, use the Security framework, described in Cryptographic Services Guide. To generate basic random values with this random source, use the methods defined in the GKRandom protocol. To generate random values with a specific range and distribution, use this random source with the GKRandomDistribution class or one of its subclasses. When you create an instance of this class, the resulting random source is both independent and deterministic—that is, the sequence of numbers generated by one instance has no effect on the sequence generated by any other instance, and that sequence can be replicated when necessary. For details on replicating sequences, see the seed property and init(seed:) initializer. note: The GKARC4RandomSource class uses a similar agorithm to, but is independent from, the arc4random family of C functions. For more information on choosing and using randomizers in GameplayKit, read Randomization in GameplayKit Programming Guide.

## Topics

### Creating a Random Source

- [init()](gameplaykit/gkarc4randomsource/init().md)
- [init(seed:)](gameplaykit/gkarc4randomsource/init(seed:).md)

### Replicating Random Behavior

- [seed](gameplaykit/gkarc4randomsource/seed.md)

### Avoiding Predictable Behavior

- [dropValues(_:)](gameplaykit/gkarc4randomsource/dropvalues(_:).md)

## Relationships

### Inherits From

- [GKRandomSource](gameplaykit/gkrandomsource.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [GKRandom](gameplaykit/gkrandom.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Randomization

- [GKRandom](gameplaykit/gkrandom.md)
- [GKRandomSource](gameplaykit/gkrandomsource.md)
- [GKLinearCongruentialRandomSource](gameplaykit/gklinearcongruentialrandomsource.md)
- [GKMersenneTwisterRandomSource](gameplaykit/gkmersennetwisterrandomsource.md)
- [GKRandomDistribution](gameplaykit/gkrandomdistribution.md)
- [GKGaussianDistribution](gameplaykit/gkgaussiandistribution.md)
- [GKShuffledDistribution](gameplaykit/gkshuffleddistribution.md)
