<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKDecisionTree/randomSource",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKDecisionTree(py)randomSource"
  },
  "title" : "randomSource"
}
-->

# randomSource

The randomizer to be used when evaluating parts of the tree that branch randomly.

```
@NSCopying var randomSource: GKRandomSource { get set }
```

## Discussion

Some of the branches in a decision tree may not depend on an external input; instead, when evaluating the tree with the [`findAction(forAnswers:)`](/documentation/GameplayKit/GKDecisionTree/findAction(forAnswers:)) method, the tree automatically chooses an answer at random. (In a manually created decision tree, you can create random branches with the [`createBranch(weight:attribute:)`](/documentation/GameplayKit/GKDecisionNode/createBranch(weight:attribute:)) method.) The tree uses this random source when randomly choosing answers.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)