<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKRuleSystem/evaluate()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKRuleSystem(im)evaluate"
  },
  "title" : "evaluate()"
}
-->

# evaluate()

Evaluates the rule system, executing the list of rules in its agenda.

```
func evaluate()
```

## Discussion

When you call this method, the system considers each rule in the [`agenda`](/documentation/GameplayKit/GKRuleSystem/agenda) list in order. The agenda contains rules in the order of their [`salience`](/documentation/GameplayKit/GKRule/salience) values, or for rules with the same salience, the order in which they were added to the system.

For each rule, the system evaluates the rule’s predicate by calling its [`evaluatePredicate(in:)`](/documentation/GameplayKit/GKRule/evaluatePredicate(in:)) method. The rule’s predicate can evaluate the system’s [`state`](/documentation/GameplayKit/GKRuleSystem/state) dictionary or call the [`GKRuleSystem`](/documentation/GameplayKit/GKRuleSystem) methods listed in Drawing Conclusions from Facts to examine the set of facts claimed by the system.

If a rule is satisfied (that is, the [`evaluatePredicate(in:)`](/documentation/GameplayKit/GKRule/evaluatePredicate(in:)) method returns <doc://com.apple.documentation/documentation/Swift/true>), the system moves that rule from the [`agenda`](/documentation/GameplayKit/GKRuleSystem/agenda) list to the [`executed`](/documentation/GameplayKit/GKRuleSystem/executed) list and performs the rule’s action by calling the rule’s [`performAction(in:)`](/documentation/GameplayKit/GKRule/performAction(in:)) method. The rule’s action can alter the system’s state dictionary or call the [`GKRuleSystem`](/documentation/GameplayKit/GKRuleSystem) methods listed in Asserting and Retracting Facts to modify the set of facts claimed by the system.

Because other rules might depend on the set of facts, asserting or retracting facts causes the system to reevaluate itself—a single call to the [`evaluate()`](/documentation/GameplayKit/GKRuleSystem/evaluate()) method can cause the system to consider its set of rules several times. After your call this method returns, the [`agenda`](/documentation/GameplayKit/GKRuleSystem/agenda) list contains only rules whose actions have not been triggered, the [`executed`](/documentation/GameplayKit/GKRuleSystem/executed) list contains rules that have executed, and the [`state`](/documentation/GameplayKit/GKRuleSystem/state) dictionary and [`facts`](/documentation/GameplayKit/GKRuleSystem/facts) array together represent the complete set of conclusions drawn by the rule system.

---

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)