What kind of AI is used for gaming npcs?

Updated 2026-07-15880 searches/moRanked #375 of 519· AI explained
Short answer

Almost no shipped game NPC uses machine learning. Game AI is hand-authored logic: finite state machines, behavior trees (the most widely used technique today, built into Unreal, Unity and CryEngine), goal-oriented action planning, and utility scoring — plus A* pathfinding over a navigation mesh. LLM-driven NPCs exist but remain mostly experimental.

Why — the first-principles explanation

The word "AI" means something different in games than in tech news, and the gap is not laziness — it's a hard engineering constraint. A game has roughly 16 milliseconds to draw a frame. In that budget it must render the world, run physics, play audio, and decide what fifty NPCs do. Each NPC gets a sliver of a millisecond. Neural network inference does not fit in a sliver of a millisecond, and never has. So game AI evolved around a completely different objective function than lab AI.

And the objective isn't intelligence at all — it's controlled, debuggable, repeatable fun. A designer needs the guard to notice you after 1.5 seconds, not 0.3 (unfair) or 4 (boring). She needs to tune that number on Tuesday and ship it Friday. Hand-authored logic gives her a knob. A learned policy gives her a black box that mysteriously changed after retraining. Studios choose knobs, every time. This is why "the AI is so dumb" is often the AI doing exactly what it was told: enemies famously walk into your line of fire because being killable is the design goal.

The main techniques stack up by expressiveness. A finite state machine is a graph of states with transitions — patrol, chase, attack, flee. Simple and cheap, but a 30-state FSM becomes an unmaintainable web of transitions. Behavior trees fixed that by making decisions modular and readable: a tree of sequence, selector and decorator nodes you can reorder without rewiring everything. That readability is why they're now the default in every major engine. GOAP goes further: give an NPC actions with preconditions, costs and effects, and a goal, and it plans its own sequence at runtime — famously used in F.E.A.R., where enemies appeared to coordinate. Utility AI scores every option each tick and picks the highest, which suits agents with many competing needs, like The Sims.

Separately, pathfinding is its own machine. A navigation mesh carves the walkable world into polygons, and A* searches that graph for a route. This is why NPCs get stuck on doorframes — the mesh, not the brain, is wrong.

An example that makes it click

Imagine directing a play. You could hire method actors who improvise every night — unpredictable, occasionally brilliant, impossible to light. Or you give each actor a script with clear cues: when the door opens, look up; if the guest stays 3 seconds, stand.

Games pick the script, and it's not because directors dislike improv. It's because the show runs 60 times a second, the director has to change the cue from 3 seconds to 1.5 on Tuesday, and 10 million people will watch it — so it has to be the same show every time. A behavior tree is that script, written in a form you can rearrange without rewriting the play.

Key facts

Infographic: What kind of AI is used for gaming npcs — short answer and key facts
Visual summary — What kind of AI is used for gaming npcs?
▶ The 60-second explainer (script)

Almost no NPC in a shipped game uses machine learning. Game AI is hand-written logic, and that's a choice, not a shortcut. Start with the constraint. A game has about 16 milliseconds to draw a frame. In that window it renders the world, runs physics, plays audio, and decides what fifty NPCs do. Each NPC gets a sliver of a millisecond. Neural network inference doesn't fit in a sliver of a millisecond. But the real reason is deeper: the goal isn't intelligence, it's controlled, debuggable, repeatable fun. A designer needs the guard to spot you after 1.5 seconds — not 0.3, that's unfair, not 4, that's boring. She needs to change that number on Tuesday and ship Friday. Hand-written logic gives her a knob. A trained model gives her a black box. Studios pick knobs every time. That's why enemies obligingly walk into your crossfire. Being killable is the design goal. The techniques: finite state machines are a graph of states — patrol, chase, attack, flee. Cheap, but they turn into spaghetti past thirty states. Behavior trees fixed that with modular, readable nodes you can rearrange — which is why they're the default in Unreal, Unity and CryEngine. GOAP gives NPCs actions with preconditions and costs and lets them plan at runtime. Utility AI scores every option and takes the best. Movement is separate: a navigation mesh plus A* pathfinding. When an NPC snags on a doorframe, the mesh is wrong, not the brain.

What authoritative sources say

Epic Developer Community — Understanding NPC Behavior in Unreal Editor for Fortniteofficial — NPCs use a navigation mesh to make pathfinding decisions and update their choices as the world updates around them. source ↗
Game AI Proorg — Behavior trees are among the most widely used game AI techniques and are available in every major game-making tool including Unreal Engine, CryEngine and Unity3D; Game AI Pro documents techniques such as tactical pathfinding on NavMesh. source ↗
arXiv — Amorphous Fortress: Observing Emergent Behavior in Multi-Agent FSMsedu — Finite state machines model agent behavior as a finite set of states with transitions; large-scale FSMs are complex to design and maintain with limited adaptability. source ↗
arXiv — Handling Concurrency in Behavior Treesedu — Behavior trees represent decision-making as a modular tree of control-flow and task nodes using sequence, selector and decorator types; concurrency and reuse are active research topics. source ↗

People also ask

Do any games use machine learning for NPCs?

A few use it in narrow places — animation blending, racing opponent lines, playtesting bots — and LLM-driven dialogue NPCs have shipped in demos and experiments. Core combat and navigation behavior in mainstream games is still hand-authored, for latency and controllability reasons.

Why does game AI seem dumb when ChatGPT seems smart?

Different goals and budgets. ChatGPT gets seconds and a datacenter. A game NPC gets a fraction of a millisecond and must be beatable on purpose. Much of what looks like stupidity is deliberate design so the player can win.

What's the difference between a behavior tree and a state machine?

A state machine tracks which state you're in and how to leave it, so adding states multiplies transitions. A behavior tree re-evaluates a tree of decisions each tick, so you can add or reorder branches without rewiring everything. That maintainability is why behavior trees won.

What is GOAP and which game made it famous?

Goal-oriented action planning gives NPCs actions with preconditions, costs and effects plus a goal, and they plan a sequence at runtime. F.E.A.R. (2005) is the classic example — its enemies appeared to coordinate flanking, which was actually independent planning over shared world state.

Why do NPCs get stuck on walls and doorways?

Usually the navigation mesh, not the decision logic. If the mesh doesn't represent that doorway correctly, A* plans a path the NPC physically can't walk, and it grinds against geometry.

Related questions