Simple Enemy AI That Feels Smart
Smart-feeling enemies are mostly simple state machines with clear signals. Here is how to design states, telegraphs and group roles that players can read and outplay.

Key takeaways
- Game AI is about being fun to fight, not about being smart. Predictable, readable behavior beats clever behavior.
- A finite state machine with four or five states (idle, patrol, alert, chase, attack, recover) covers most enemies.
- Telegraph every attack with a windup the player can see and hear, and give a recovery window to punish.
- Groups feel smart when enemies take turns and fill different roles, not when each one is individually clever.
Enemy AI that feels smart is usually simple: a small finite state machine (idle, patrol, alert, chase, attack, recover), a limited sense of sight and hearing, and clear signals before every attack. Players read intelligence from behavior they can understand and react to, so the goal is not an enemy that plays optimally, but one that telegraphs its intent, makes believable decisions and leaves openings to exploit. Add simple group rules, like taking turns to attack, and a handful of these enemies will feel like a coordinated squad.
Fun to fight beats smart
A perfectly accurate enemy that always dodges and never misses is easy to build and miserable to fight. Game AI is a performance: its job is to create interesting situations for the player. That means deliberately adding weaknesses: reaction delays, imperfect aim, pauses after attacks, and limits on how many enemies attack at once.
The classic maze game with four ghosts is the best-known example. Each ghost follows a very simple targeting rule: one heads straight for the player, one aims a few tiles ahead of where the player is facing, one uses a target calculated from the player and another ghost's position, and one chases until it gets close, then retreats to its corner. They also periodically scatter to their home corners. None of them is clever, but together they produce the feeling of being hunted and ambushed, and players learn to read them.
Finite state machines: the workhorse
A finite state machine (FSM) means the enemy is always in exactly one state, each state has its own behavior, and specific events move it between states. A typical melee enemy:
- Idle or patrol: walk between waypoints or wander in a small area. Transition to Alert when the player is seen or heard.
- Alert: stop, turn toward the player, play a "!" signal or sound for about 0.3 to 0.8 seconds. Transition to Chase. This short pause is what makes detection feel fair.
- Chase: move toward the player. Transition to Attack when in range, or to Search if the player is out of sight for a few seconds.
- Attack: windup (telegraph), strike, then go to Recover.
- Recover: a vulnerable pause of 0.5 to 1.5 seconds after attacking. Back to Chase.
- Search: go to the last known position, look around for a few seconds, then return to Patrol.
- Hurt and Dead: short stagger on hit, death animation and removal.
Draw this as boxes and arrows before building it. Each arrow should have a clear condition ("player within 6 meters and visible"). Enemies with very different behaviors (a flying enemy, a turret, a summoner) are just different diagrams. When the diagrams get large, designers move to behavior trees, which organize decisions as a hierarchy of priorities, but most small games never need one. The top-down shooter guide lists six enemy archetypes built from states like these.
Perception: what enemies can sense
Enemies that know where you are through walls feel unfair. Give them limited senses, and make those senses visible to the player when possible:
- Sight cone: a range (say 8 to 12 meters, or a few screens of tiles) and an angle (90 to 120 degrees in front). Check line of sight with a ray so walls block vision.
- Hearing radius: running, shooting and breaking things make noise that alerts enemies within a radius, even behind them. Sneaking makes less.
- Memory: remember the last known position for a few seconds after losing sight, then search there. This single feature makes enemies feel much smarter.
- Alert sharing: an alerted enemy alerts others nearby after a short delay, often with a shout. Players see the alarm spread and understand why.
Telegraphing: the key to fair difficulty
A telegraph is the signal before an attack: a windup pose, a flash, a sound, a ground marker. It turns attacks from random damage into a pattern the player can learn and react to. Guidelines:
- Windup length: roughly 0.4 to 1.0 seconds for regular enemies, shorter for fast weak attacks, longer for heavy ones. Human reaction time to a clear visual cue is commonly around a quarter of a second, so anything faster than that is hard to react to fairly.
- Multiple channels: a pose change plus a sound plus a color flash. Players often hear attacks before they see them.
- Danger zones: show where an area attack will land (a red circle on the ground that fills up).
- Consistency: the same windup always means the same attack. Fake-outs are fine for bosses, used sparingly.
- Punish windows: after a big attack, the enemy recovers and is open to counterattack. This creates a rhythm of dodge, then strike.
Design enemies by role
Variety comes from roles more than from different art. Each role asks the player to do something different:
- Grunt: approaches and attacks directly. Teaches basic combat.
- Ranged: keeps distance and shoots. Forces the player to close in or use cover.
- Tank: slow, high health, blocks paths. Forces positioning.
- Charger: telegraphs, then rushes in a straight line. Teaches dodging sideways.
- Flanker: circles to attack from the side or behind. Forces awareness.
- Support: heals, shields or summons others. Creates target priority decisions.
Introduce roles one at a time, then combine them. A grunt and a ranged enemy together create a problem neither creates alone. This is the same teach, test, twist idea from our level design basics, applied to enemies.
Group behavior that feels coordinated
- Attack tokens: only two or three enemies may attack at once. Others circle, reposition or taunt while waiting their turn. Many action games use this so crowds feel dangerous but fights stay readable.
- Spacing: enemies push away from each other slightly (separation), so they do not stack into a single blob.
- Surround slots: assign chasers to positions around the player rather than all heading for the same point.
- Call-outs: a shout or gesture when one enemy flanks or throws a grenade makes the coordination visible, which is most of what makes it feel smart.
- Retreat when weak: an injured enemy that backs off and calls for help reads as intelligent with one extra rule.
A brief for enemy AI
Describing AI as states and numbers gives an agent much less to guess. In Startbase, ask for the tuning values to be dials in the Engine panel, described in the games template docs, so you can adjust sight range or windup time while playing:
Give the goblin enemies in my top-down game a state machine: Patrol between 2 to 4 waypoints; Alert for 0.5 s with a "!" icon and a grunt sound when the player enters a 100 degree sight cone within 8 m with clear line of sight, or makes noise within 5 m; Chase; Attack with a 0.6 s windup (crouch, red flash, swoosh sound) then a lunge; Recover for 1 s, vulnerable; Search the last known position for 4 s if the player is out of sight for 3 s. An alerted goblin alerts others within 6 m after 0.4 s. At most 2 goblins attack at once; the rest circle at 3 m. Expose sight range, windup and recover time as Engine panel dials, and add a debug label showing each goblin's state.
Common enemy AI mistakes
- Instant reactions: enemies that turn and shoot the frame they see you.
- Perfect aim: add spread, lead errors or a short aim delay.
- Everyone attacks at once: overwhelming and unreadable.
- Getting stuck: enemies walking into walls or corners. Test chase paths around every obstacle shape, and give stuck enemies a fallback (a short random move, or teleporting off-screen).
- Invisible state changes: if players cannot tell an enemy has noticed them, detection feels random.
The same principles scale up to bosses, which are essentially one enemy with several state machines in sequence; see our boss fight design guide. And because AI behavior is easiest to judge by watching others play, share a preview and see whether players can describe what each enemy does after one encounter. For a monster that hunts by sound, see how to make a horror game.
Frequently asked questions
What is a finite state machine in game AI?
A model where an enemy is always in one state, such as patrol, chase or attack, each with its own behavior, and specific conditions move it between states. It is simple to build, easy to debug and enough for most enemies in small games.
How do I make enemies feel smarter without making them harder?
Make their behavior visible and believable: alert signals when they spot you, memory of where they last saw you, call-outs to allies, and turn-taking in groups. Readable behavior feels intelligent even when the rules are simple.
What is telegraphing in games?
The visual and audio warning before an attack, such as a windup pose, a flash, a sound or a ground marker. It gives players time to react and lets them learn enemy patterns, which makes difficulty feel fair.

