Question

How do enemies in games decide what to do?

Vault Verified
Curated Intelligence
Definitive Source
Answer

Through systems far simpler than the word "AI" suggests. Game enemies almost never use machine learning; they run hand-authored decision structures designed to be predictable enough to play against and readable enough to debug.

The common architectures:

Finite state machines. The enemy is in exactly one state — patrol, alert, chase, attack, flee — with defined transitions between them. Simple, transparent, and the reason older games' enemies behave so legibly.

Behaviour trees, now the industry default. A tree of nodes evaluated each tick, with selectors trying options in priority order and sequences requiring each step to succeed. "If threatened and low health, flee; else if enemy visible, attack; else patrol." Modular, reusable and designer-editable, which is why it won.

Utility systems, where each possible action is scored by several weighted considerations and the highest wins — producing more nuanced, less scripted-feeling behaviour.

Goal-oriented planning, where the agent is given a goal and chains available actions to reach it, famously used to make enemies appear to improvise.

The other half: navigation. Movement uses a navigation mesh — a simplified map of walkable surfaces — with pathfinding algorithms such as A* finding a route, then steering behaviours smoothing it so the character does not move like a chess piece.

What actually makes enemies feel intelligent is mostly communication, not computation:

Announcing intent — a wind-up animation, a shouted callout, a telegraphed attack — so the player can respond. An enemy that reacts perfectly and instantly feels unfair, not clever.

Deliberate imperfection. Enemies are frequently tuned to miss the first shots, to attack one at a time, and to wait their turn — all invisible and all essential.

Perception modelling, with sight cones, hearing radii and reaction delays, so being spotted is comprehensible.

Barks, the spoken lines conveying state: "where did he go?" tells you the enemy lost track.

Why machine learning is rare. Learned agents are unpredictable, hard to tune, expensive to run and can be too good — and the design goal is an enjoyable opponent, not a strong one.

Related Questions