game-ai
What it does
This skill explains how to make game characters decide what to do, how to move, and how to find a path around obstacles. It is for game developers building enemies, guards, or groups of moving characters.
When to use it
- βWhen you are building enemy patrol, chase, or guard behavior.
- βWhen you need to pick between a state machine, behavior tree, or steering for a character.
- βWhen an enemy must find a path around walls to reach the player.
Skill link
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/game-ai/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI want my guard enemy to patrol, chase me when it sees me, and go back to its post when I escape. Which AI approach should I use?β
5 new skills a week. 1 minute to read.
How it works
The agent recommends a simple state machine for a few clear states, a behavior tree for many prioritized behaviors, or scoring for graded choices. It keeps decisions, movement, and pathfinding separate so each part is easier to change.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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)
# Godot 4.7, one class per file.
# state.gd: each state is a small object with enter/update/exit.
class_name State extends RefCounted
func enter(_agent) -> void: pass
func update(_agent, _dt: float) -> State: return null # return a state to transition
func exit(_agent) -> void: pass
# chase.gd: returns Patrol when the player escapes sight range.
class_name Chase extends State
func update(agent, dt: float) -> State:
if not agent.can_see(agent.target):
return Patrol.new() # transition by returning the next state
agent.move_toward(agent.target.position, dt)
return null # null = stay in this state
# enemy.gd: the agent owns `current` and ticks it once per frame.
var current: State = Patrol.new() # call current.enter(self) in _ready()
func tick(dt: float) -> void:
var next := current.update(self, dt)
if next != null:
current.exit(self)
next.enter(self)
current = next
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 node's tick() returns SUCCESS, FAILURE, or RUNNING (still working this frame).
enum Status { SUCCESS, FAILURE, RUNNING }
# Sequence: run children in order; stop at the first non-SUCCESS (logical AND).
func sequence_tick(children, agent, dt) -> int:
for child in children:
var s = child.tick(agent, dt)
if s != Status.SUCCESS:
return s # FAILURE or RUNNING short-circuits the sequence
return Status.SUCCESS
# Selector: try children until one succeeds or is RUNNING (logical OR / fallback).
func selector_tick(children, agent, dt) -> int:
for child in children:
var s = child.tick(agent, dt)
if s != Status.FAILURE:
return s # SUCCESS or RUNNING stops the search
return Status.FAILURE
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
FAQ
What is steering?
Steering is smooth local movement, such as seeking a target or flocking with a group.
Does it cover my engine's navigation system?
The engine's own navigation API is covered by related engine skills, which this one points to.
Is A* included?
Yes. The skill covers A* on a grid or graph for finding paths.
Details
Original description by the author
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.
Popularity
- GitHub stars
- 6.6k
- Ranking position
- #13796
- License
- Apache-2.0
- Updated
- 10/28/2026
Comments
- β¦
More skills from this repository
router
6.6kHelps your agent pick the right game development skill for a request by detecting your engine and the kind of task you need.
ai-behavior-trees-utility-ai
6.6kHelps your agent build a behavior tree and utility AI system for game enemies and characters that choose actions by priority and score.
audio-design
6.6kTeaches your agent game audio mixing: buses, decibel volume, ducking under dialogue, adaptive music and sound effect variation.
camera-systems
6.6kHelps your agent build game cameras that follow smoothly, stay inside the level, and orbit or look around in 3D.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.