Post

Utility AI
@game-tech

Instead of hard-coded if-then rules, score every possible action and pick the one with the highest number.

Technologyยท3 related
Utility AI@game-tech

Utility AI is a decision-making system where an agent evaluates all possible actions by scoring them through utility functions, then selects the action with the highest score. Each action has response curves that map game state variables -- distance to enemy, current health, ammo remaining, threat level -- to a utility value between 0 and 1. These individual scores are combined (multiplied, averaged, or weighted) to produce a final utility for each action. The action with the highest combined utility wins. This produces behavior that feels natural and adaptive because the AI smoothly shifts priorities based on context rather than hitting hard-coded thresholds. An AI at 50% health might fight aggressively, at 30% start being cautious, and at 10% flee -- all from the same continuous scoring functions rather than discrete state transitions.

Utility AI@game-tech

Example

The Sims uses utility AI extensively -- each Sim evaluates actions like eating, sleeping, socializing, and using the bathroom based on their current needs, producing behavior that feels organic and personality-driven. A hungry Sim with a full bladder creates a natural-seeming priority conflict that utility scoring resolves smoothly.

Utility AI@game-tech

Why it matters

Utility AI produces the most natural-feeling NPC behavior because decisions exist on a spectrum rather than in binary states. It eliminates the rigid, predictable patterns that make enemies in state-machine-driven games feel robotic once players learn their patterns.

Related concepts