Field Notes: Design
Game AI isn't judged by how smart it is but by how it feels to play against. These notes are the design lessons that teams usually learn from playtests, not from algorithms. The technical side (budgets, time-slicing, debugging) is in Field Notes: Performance.
1. Fun beats smart
An enemy that plays optimally is easy to write and miserable to fight: it flanks perfectly, never misses and focuses the weakest player. The enemy's job is to lose interestingly, ideally in a way that makes the player feel clever.
- Make the first shot miss. Many shooters make an enemy's first shots after spotting you land near you, not on you. The player gets a warning and a chance to react, and the fight still feels dangerous.
- Prefer visible intent to hidden optimality. A guard who shouts "Flanking left!" and then does it is more fun than one who silently picks the mathematically best cover. The player can counter what they understand.
- Leave exploitable habits. Enemies who always check the last noise, or always throw a grenade at camping players, give players tools. Patterns are content.
- Tune with playtests, not with win rates against bots. "The AI beat the player 70% of the time" says nothing about whether those fights were fun.
2. Telegraph every attack
Players can only dodge what they can see coming. Every attack needs a windup (anticipation pose, glow, sound, a line on the floor) that is longer than the time a player needs to react and start the dodge. Human visual reaction time is often quoted at around a quarter of a second, and that's for a player who is already looking and waiting. Then add the dodge's own startup.
using System;
const double reaction = 0.25, dodgeStartup = 0.10;
double needed = reaction + dodgeStartup;
var attacks = new (string name, double windup)[]
{
("Jab", 0.15), ("Grab", 0.30), ("Lunge", 0.40), ("Overhead slam", 0.60), ("Tail sweep", 0.90),
};
Console.WriteLine(quot;player needs {needed:F2} s to react and start a dodge");
foreach (var (label, scale) in new[] { ("Normal", 1.0), ("Hard (windups x0.8)", 0.8) })
{
Console.WriteLine(label);
foreach (var (name, windup) in attacks)
{
double w = windup * scale;
string verdict = w >= needed ? "fair" : w >= reaction ? "tight: needs a pre-read" : "UNFAIR: can't be reacted to";
Console.WriteLine(quot; {name,-14} windup {w:F2} s {verdict}");
}
}player needs 0.35 s to react and start a dodge
Normal
Jab windup 0.15 s UNFAIR: can't be reacted to
Grab windup 0.30 s tight: needs a pre-read
Lunge windup 0.40 s fair
Overhead slam windup 0.60 s fair
Tail sweep windup 0.90 s fair
Hard (windups x0.8)
Jab windup 0.12 s UNFAIR: can't be reacted to
Grab windup 0.24 s UNFAIR: can't be reacted to
Lunge windup 0.32 s tight: needs a pre-read
Overhead slam windup 0.48 s fair
Tail sweep windup 0.72 s fair
A fast jab is fine if it does little damage or can be predicted from context (it always follows a step forward). What isn't fine is a big hit that can't be reacted to. The second table shows a common mistake: making "Hard" mode shorten windups, which turns the grab into an unreactable attack and the lunge into a guess, without the player having learned anything new. Make harder difficulties shorten recovery (the punish window after the attack), add attacks to combos, or add enemies instead, and keep windups readable.
3. Limit simultaneous attackers
Five melee enemies surrounding the player and all swinging at once is unreadable and unfair. Action games commonly hand out attack tokens: a small pool owned by the player, and an enemy must hold one to attack. Enemies without a token circle, taunt, reposition, or shoot from range, which also looks more alive.
using System;
using System.Collections.Generic;
using System.Linq;
var enemies = new List<Enemy>
{
new("A", 2.0), new("B", 3.5), new("C", 1.5), new("D", 4.0), new("E", 2.5),
};
const int maxTokens = 2;
const int attackTicks = 2, cooldownTicks = 3;
for (int tick = 0; tick < 8; tick++)
{
foreach (var e in enemies) // finish attacks, return tokens
{
if (e.AttackLeft > 0 && --e.AttackLeft == 0) { e.HasToken = false; e.Cooldown = cooldownTicks; }
else if (e.Cooldown > 0) e.Cooldown--;
}
int free = maxTokens - enemies.Count(e => e.HasToken);
foreach (var e in enemies.Where(e => !e.HasToken && e.Cooldown == 0).OrderBy(e => e.Distance).Take(free))
{
e.HasToken = true; // closest ready enemies get tokens
e.AttackLeft = attackTicks;
}
string attacking = string.Join(",", enemies.Where(e => e.HasToken).Select(e => e.Name));
string circling = string.Join(",", enemies.Where(e => !e.HasToken).Select(e => e.Name));
Console.WriteLine(quot;tick {tick}: attacking {attacking,-4} circling {circling}");
}
class Enemy(string name, double distance)
{
public string Name = name;
public double Distance = distance;
public bool HasToken;
public int AttackLeft, Cooldown;
}tick 0: attacking A,C circling B,D,E
tick 1: attacking A,C circling B,D,E
tick 2: attacking B,E circling A,C,D
tick 3: attacking B,E circling A,C,D
tick 4: attacking D circling A,B,C,E
tick 5: attacking C,D circling A,B,E
tick 6: attacking A,C circling B,D,E
tick 7: attacking A,E circling B,C,D
Every enemy gets a turn, never more than two swing at once, and the cooldown stops the closest two from hogging the tokens. Real systems add tweaks: ranged and melee tokens in separate pools, more tokens on higher difficulty, and an enemy the player is attacking or looking at gets priority, so the fight happens where the player's attention is.
4. Cheat honestly
Almost every game AI cheats: it knows where the player is, it reads inputs, racing opponents speed up when they fall behind. Cheating is fine. Getting caught is not. Rules that keep it honest:
- Act only on information the player could explain. A director system may know where the player is, to spawn enemies out of sight or send a patrol in the right general direction. Individual enemies should still go through perception: they search the last known position (Memory & Awareness) instead of walking straight to a hidden player.
- Show what the AI knows. Suspicion meters, alert icons and barks ("Did you hear that?", "Lost him!") turn perception into feedback. When the player can see why they were found, being found feels fair.
- Rubber-band within limits. A racing opponent can get a small speed boost when far behind, but cap it, apply it out of the player's view, and never let it win a photo finish it couldn't have won fairly. Players notice a rival who is always exactly one car-length behind.
- Cheat in the player's favour more than against. Lower enemy accuracy when the player is low on health, give the last enemy in a wave less aggression. Players rarely complain about a lucky escape.
5. Barks and readable states
Each AI state should be visible and audible: a different walk for patrol and search, a sound when an enemy gives up, an animation when it spots you. Barks (short voice lines) are the cheapest way to make AI look smart: "Covering fire!" makes an ordinary suppression behavior read as teamwork (Squad Coordination). Throttle them, though: one bark per event, a cooldown per line, and only one speaker at a time in a squad.
Test yourself
Your Hard mode feels cheap. Playtesters say they can't dodge the boss lunge any more. What is the better difficulty knob?
- Shorten the lunge windup further
- Keep windups readable; shorten recovery windows, add combo attacks or add enemies
- Give the boss more health
- Remove the windup animation
What problem do attack tokens solve?
- Path requests per frame
- Too many enemies attacking at once, which is unreadable and unfair
- Saving the game
- Animation blending
An enemy walks straight to a player hiding in a closet it never saw. What is the honest fix?
- Make the closet invisible
- Route enemy knowledge through perception and last known position; let only the director use global knowledge, indirectly
- Remove closets
- Give the player a speed boost