Back to Skills

game-ai

Design NPC and enemy decision-making with finite state machines, behavior trees, steering behaviors, and A* pathfinding — engine-neutral algorithms that pair with the detected engine's navigation API. Use when building enemy AI, an FSM or behavior tree, steering/flocking, or pathfinding, or when the user mentions state machine, behavior tree, blackboard, A*, navmesh, seek, or patrol/chase.

532stars42forksUpdated 8/17/2026

Security Assessment

Safe(95/100)
Security Score95/100

About game-ai

This skill teaches how to design NPC and enemy decision-making using engine-neutral algorithms: finite state machines, behavior trees, steering behaviors, and A* pathfinding. It solves the problem of building believable AI by separating three layers — decide (what to do), steer (how to move there), and path (how to route around the map) — and keeping them decoupled so a behavior tree picks a target, the pathfinder produces waypoints, and steering follows them. The algorithms are meant to bind to whichever engine is detected via companion engine skills.

The core workflow helps pick a decision model by complexity (FSM for a few clear states, behavior tree for many reactive prioritized behaviors, utility scoring for continuous preference), separate decision from motion, path on the right graph, steer along the path rather than straight to the goal, recompute paths sparingly, and verify by on-screen observation. Reference material provides a full behavior-tree node taxonomy (sequence, selector, parallel, decorators, condition and action leaves), stateful composites that resume a RUNNING child, the blackboard as shared decoupling memory, an FSM-versus-BT decision table, a brief on utility AI, and a complete engine-neutral A* implementation with heuristic admissibility notes and path reconstruction. Code samples are shown in GDScript and Python.

The target users are game developers and designers implementing enemy AI, patrol/chase/guard logic, group movement, or pathfinding, in any engine. Use cases include choosing between an FSM and a behavior tree, wiring a blackboard, and integrating A* on a grid or driving a navmesh agent.

FAQ

What AI techniques does this skill cover?

Finite state machines, behavior trees (with a full node taxonomy and blackboard), steering behaviors, utility AI scoring, and A* pathfinding — all as engine-neutral algorithms.

How do I choose between an FSM and a behavior tree?

Use an FSM for 2–5 clearly named states with few obvious transitions; use a behavior tree for many prioritized, interruptible, reusable behaviors. Many games use both — an FSM for top-level mode and a behavior tree inside a combat state.

Is it tied to a specific game engine?

No. The algorithms are engine-neutral, with examples in GDScript and Python. For concrete navmesh/agent APIs it defers to engine-specific skills like unity-navmesh or unreal-behavior-trees.

How does it recommend handling pathfinding performance?

Path on the graph with the fewest nodes, prefer a baked navmesh for 3D and A* on a grid for tile games, recompute paths on a timer or when the goal moves a tile (not every frame), and cache the path so only the waypoint index advances.

What guarantees does the A* implementation give?

A* is optimal as long as the heuristic never overestimates the true remaining cost (it is admissible); with a zero heuristic it degenerates to Dijkstra's algorithm.

All Files

3 files
references/behavior-trees.md4.8 KB
View
references/pathfinding.md4.8 KB
View
SKILL.md7.8 KB
View

Install game-ai

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill