From workflows
Teaches engine-neutral NPC decision-making with finite state machines, behavior trees, steering behaviors, and A* pathfinding. Use when implementing enemy AI, patrol/chase logic, or integrating pathfinding with an engine navmesh.
How this skill is triggered — by the user, by Claude, or both
Slash command
/workflows:game-aiThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Build believable NPC behavior from three separable layers: **decide** (what to
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 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.
# Each state is a small object with enter/update/exit. The machine owns "current".
class_name State
func enter(agent): pass
func update(agent, dt) -> State: return null # return a new state to transition
func exit(agent): pass
# --- Chase state: returns Patrol when the player escapes sight range ---
class Chase extends State:
func update(agent, dt) -> State:
if not agent.can_see(agent.target):
return Patrol.new() # transition by returning next state
agent.move_toward(agent.target.position, dt)
return null # null = stay in this state
# --- Driver: call once per frame ---
func tick(dt):
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.
# 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 blackboard.
# Seek: accelerate toward a target at full speed. Steering = desired - current.
func seek(pos, vel, target, max_speed, max_force) -> Vector2:
var desired = (target - pos).normalized() * max_speed
return (desired - vel).limit_length(max_force) # a force, not a teleport
# Arrive: like seek, but ramp speed down inside slow_radius so it stops cleanly.
func arrive(pos, vel, target, max_speed, max_force, slow_radius) -> Vector2:
var offset = target - pos
var dist = offset.length()
if dist < 0.001: return -vel # already there: kill drift
var ramped = max_speed * min(dist / slow_radius, 1.0)
var desired = offset / dist * ramped
return (desired - vel).limit_length(max_force)
# Per frame: vel += steering * dt; pos += vel * dt (always scale by dt)
# Match the heuristic to the movement. An ADMISSIBLE heuristic (never larger
# than the true remaining cost) keeps A* optimal.
def heuristic(a, b):
dx, dy = abs(a.x - b.x), abs(a.y - b.y)
# return dx + dy # Manhattan: 4-direction grids (no diagonals)
return (dx + dy) + (1.414 - 2) * min(dx, dy) # octile: 8-direction grids
# f(n) = g(n) + h(n): g = cost from start, h = heuristic to goal.
# Overestimating h is faster but no longer guarantees the shortest path.
The full A* loop (priority queue, came_from reconstruction, grid + waypoint
graphs) is in references/pathfinding.md.
if state == ... checks everywhere
recreates the mess an FSM exists to prevent. Keep transitions in the state.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.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.npx claudepluginhub gamedev-skills/awesome-gamedev-agent-skills --plugin gamedevDesigns and implements game AI systems including behavior trees, FSMs, GOAP, utility AI, pathfinding, and steering behaviors. Specializes in believable NPC behaviors for enhanced player experience.
Design maintainable AI behavior structures for decision-making, navigation, combat, and systemic interaction.
Walks NPC AI design from perception through action, intent, personality knobs, and defeat handling. Outputs a GDScript state-machine stub and node tree for enemies, bosses, companions, civilians, or wave-spawned mobs. Trigger on 'enemy', 'NPC', 'behavior'.