What “AI” means in a game
Game AI is a looser idea than the artificial intelligence discussed in the news. In a game, it usually means the code that decides what non-player characters do: how an enemy moves, when it attacks, how an ally follows you, how a rival car takes a corner. The aim is not to be as smart as possible. It is to make the game feel believable and fun, and that often means being deliberately beatable.
This article does not include figures about adoption or trends, because no verified data is available. It explains how the classic techniques work and how they differ from modern machine learning.
State machines: the workhorse
One of the oldest and most common tools is the finite state machine. A character is always in one state, such as patrolling, chasing, attacking or fleeing, and rules define what makes it switch.
A simple guard might work like this:
- Patrol: walk a route. If the player is seen, switch to chase.
- Chase: move toward the player. If the player is close enough, switch to attack. If the player escapes, switch to search.
- Search: look around the last known position. If nothing is found for a while, return to patrol.
State machines are popular because they are easy to understand, test and debug. Their weakness is that a large number of states and connections becomes hard to manage, so designers sometimes use related structures to organise behavior in layers, such as behavior trees. These keep the same basic idea of clear, rule-based decisions.
Pathfinding: getting from A to B
For a character to move sensibly, it needs a route around walls, furniture and other obstacles. Pathfinding handles this. The game typically represents walkable space as a map of connected points or areas, such as a grid or a navigation mesh, and then searches for a short route through it. A widely used family of search methods works by exploring promising routes first and estimating the remaining distance to the goal.
Pathfinding has practical complications. Routes must adapt when things move, many characters must avoid each other, and the result must look natural rather than robotic. These issues are part of why crowds and followers sometimes get stuck in games.
Perception and the illusion of awareness
Enemies need to know what they can see and hear. Designers usually give them limited senses, such as a view cone and a hearing radius, rather than perfect knowledge. This makes stealth possible and gives players something to exploit.
Many games also let AI “cheat” in ways players do not notice, for example by giving a computer opponent slightly better information than a human would have. Whether this is fair is a design choice, and it relates to game difficulty. Often the opposite is done: enemies are given deliberate flaws, like slow reactions or missed shots, so that the player can win.
Other classic techniques
- Scripting: fixed sequences for scenes or tutorials.
- Utility scoring: the character rates available actions by how useful each seems and picks the best.
- Planning: the character chooses a series of actions to reach a goal.
- Tree search for board-like games: programs for strategy or board games look ahead through possible moves.
None of these require the system to learn. A designer writes the behavior, and the character follows it.
How this differs from machine learning
Machine learning builds behavior from data or practice instead of hand-written rules. A system is trained and then produces outputs based on what it learned. It is a different approach, with different strengths.
Hand-written AI is predictable and controllable, which is valuable when a game must feel fair and be repeatable. Learned systems can handle patterns that are hard to write by hand, but they can behave unexpectedly, need data and computing power, and are harder to tune toward a specific feel. For these reasons, much of what players meet as enemy behavior is still traditional rule-based AI, though practices vary and the details of any particular game are often not public.
Machine learning is more often discussed in relation to how games are made and run, which is a separate topic covered under AI in development.
Reading claims about AI in games
Statements about trends in game AI call for care.
- Terminology is loose. “AI” in marketing may mean simple scripted behavior, a learned model, or just a feature that sounds advanced.
- Players often cannot tell. From the outside, a clever state machine and a learned system can look similar.
- Impressive demos are not typical games. A research result does not mean a shipped game uses the technique.
- Few developers share their methods, so surveys about adoption depend on who responded.
What good game AI feels like
The best game AI tends to be readable. The player can tell what an enemy is about to do, learn its pattern and respond. It is less about brilliance than about giving the player a good fight, a believable companion or a fair rival.