trung-hust/agent-skills/game-ai
Claude Code and agent skill by trung-hust/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install trung-hust/agent-skills/game-aiSKILL.md
The same SKILL.md was published earlier as gamedev-skills/awesome-gamedev-agent-skills/game-ai.
Game AI: decisions, steering, and pathfinding
Build believable NPC behavior from three separable layers: decide (what to do), steer (how to move there), and path (how to route around the map). Keep them decoupled — a behavior tree picks a target, the pathfinder produces waypoints, steering follows them. This skill teaches the engine-neutral algorithms; bind them to your engine via the related skills below.
When to use
- Use when implementing enemy/NPC logic: patrols, chase/flee, guard states,
group movement, or "find a path to the player".
- Use to choose between an FSM (few clear states), a behavior tree (many
reactive behaviors with priorities), or steering (smooth local movement).
- Use when integrating pathfinding: A* on a grid/graph, or driving an engine
navmesh agent.
When *not* to use: for the engine's concrete navmesh/agent API and baking, use unity-navmesh, unreal-behavior-trees, or Godot's NavigationAgent2D/3D (see that engine skill). For movement/collision feel, use physics-tuning. For spawning waves along lanes, see the tower-defense genre skill.
Core workflow
- Pick the decision model by complexity. 2–5 states with obvious
transitions → FSM. Many behaviors, priorities, interruption, reuse → behavior tree. Continuous "how strongly do I want each option" → utility scoring.
- Separate decision from motion. The decision layer outputs an intent
(target position, action). Steering or pathfinding turns intent into motion.
- Path on the right graph. Grid tiles, waypoint graph, or a baked navmesh.
Fewer nodes = faster A. Prefer the engine's navmesh for 3D; A on a grid for tile games.
- Steer along the path, not straight to the goal — follow the next waypoint,
advancing when close, so agents round corners.
- Recompute paths sparingly. Pathfind on a timer or when the goal moves a
tile, not every frame. Cache the path; only the waypoint index advances.
- Verify by observation. Watch the agent: does it reach the goal, get stuck
on corners, oscillate between states? Draw the path and current state on screen while tuning.
Patterns
1. Finite state machine (one state object, explicit transitions)
Keep transition logic inside states (or in a table), never as a growing pile of if flags. One state owns one behavior; that is what keeps an FSM readable.
2. Behavior tree tick (composite nodes return a status)
A guard AI reads top-down: Selector[ Sequence[CanSeePlayer?, Chase], Patrol ] — chase if visible, otherwise patrol. See references/behavior-trees.md for leaf nodes, decorators (Inverter, Cooldown), and a blackboard.
3. Steering: seek and arrive (smooth, frame-rate independent)
4. A* heuristic must not overestimate (or paths stop being shortest)
The full A* loop (priority queue, came_from reconstruction, grid + waypoint graphs) is in references/pathfinding.md.
Pitfalls
- Pathfinding every frame tanks the frame rate. Recompute on a timer or only
when the target moves to a new tile; follow the cached waypoints in between.
- Steering straight to the goal instead of to the next waypoint makes agents
hug walls and corners. Follow the path; advance the waypoint when within radius.
- Inadmissible A\* heuristic (e.g. Euclidean distance scaled up, or Manhattan
on a diagonal grid) returns fast but non-shortest paths. Pick the heuristic that matches your allowed moves.
- Behavior tree leaves that never return RUNNING for multi-frame actions
(walking, playing an animation) cause the tree to restart the action every tick. Return RUNNING until the action completes.
- FSM transition spaghetti: scattering
if state == ...checks everywhere
recreates the mess an FSM exists to prevent. Keep transitions in the state.
- No line-of-sight or stuck check → agents grind into walls forever. Add a
timeout that forces a repath or a state change.
References
references/pathfinding.md— complete A* (priority queue, reconstruction),
grid vs waypoint graphs, when to defer to an engine navmesh.
references/behavior-trees.md— node taxonomy, leaf/decorator implementations,
blackboard, and FSM-vs-BT selection.
Related skills
unity-navmesh,unreal-behavior-trees— concrete engine AI/navigation APIs.physics-tuning— movement, collision response, and agent radius.procedural-gen— generating the graph/level the AI navigates.tower-defense,fps-shooter— genres that compose this skill.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtemplate/.agents/skills/game-ai/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/trung-hust/agent-skills/game-ai)