Back to Wiki
Applications
Last updated: 2024-12-255 min read

Gaming AI

AI agents in video games

Gaming AI

Game AI refers to the techniques used to create responsive, adaptive, and intelligent behaviors in non-player characters (NPCs) within video games. Unlike academic AI, the goal of Game AI is often not "optimality" but "believability" and "fun."

Approaches to Game AI

1. Finite State Machines (FSMs)

One of the oldest and most common techniques. An NPC can be in a specific state (e.g., "Idle," "Patrol," "Chase," "Attack"). Transitions between states are triggered by events (e.g., seeing the player triggers "Patrol" -> "Chase").

2. Behavior Trees

A more flexible alternative to FSMs. They organize behaviors in a tree structure. The AI traverses the tree to find the first executable action. This allows for complex, hierarchical behaviors and is used in games like Halo and The Last of Us.

3. Utility Systems

Instead of strict rules, possible actions are scored based on "desirability." An NPC might consider hunger, safety, and energy. If "hunger" is high, the "Eat" action gets a high score. Used in The Sims and Fallout.

4. GOAP (Goal-Oriented Action Planning)

The AI has a goal (e.g., "Kill Player") and a list of possible actions. It dynamically plans a sequence of actions to achieve that goal. Famous for its use in F.E.A.R..

Advanced Techniques

Reinforcement Learning (RL)

While older games used scripted AI, modern research (and some games) use RL where agents learn to play by playing millions of matches against themselves.

  • OpenAI Five: Defeated champions in Dota 2.
  • AlphaStar: Reached Grandmaster level in StarCraft II.

Procedural Content Generation (PCG)

AI agents aren't just characters; they can be "Director" agents that generate levels, quests, or difficulty adjustments on the fly to keep the player engaged.

The Future: Generative Agents

With the rise of LLMs, we are seeing the emergence of "Generative Agents"—NPCs that don't rely on pre-written dialogue trees but generate conversation and behavior dynamically.

  • Dynamic Dialogue: Talking to NPCs about anything in the game world.
  • Memory: NPCs that remember past interactions with the player.
  • emergent Behavior: Complex social dynamics arising from simple agent interactions.

Key Differences from Academic AI

  • Resource Constraints: Game AI must run in milliseconds alongside graphics and physics physics.
  • Cheating: It's often acceptable for Game AI to "cheat" (know player position) to maintain challenge, as long as the player doesn't notice.
  • Intentional Stupidity: A perfect AI sniper is not fun. Game AI is often programmed to miss or hesitate to give the player a chance.