“I want to build a computer opponent that is hard to beat and fun to play against.”
An AI opponent is a program that plays a game against a person. It runs one loop many times a second or once a turn: it reads what it knows of the game, decides, and acts through units that must move and fight. Its decisions sit in layers. A strategic layer picks goals, the army to field and the economy to pay for it, a tactical layer runs each fight, and movement carries out the orders. Where both sides order at once, it must also predict the other side's sealed orders and mix its own plans, because a plan that never varies can be countered before it lands. The goal is the player's experience, not the win, so difficulty, personality and legibility make the AI a rival people can read, beat and want to face again, and testing against other AIs and against people finds the blind spots a player could exploit every game.
Product
AI opponent
You might say: computer opponent, CPU player, computer player, AI player, enemy AI, bot, skirmish AI, artificial opponent, game AI
A player run by the computer that competes against a person in a game. Over and over, it reads what it knows of the game, decides and acts, until the match ends.
- Ask
- Does it give this player a fight that is hard to win, fair to lose and readable enough to learn from, with no blind spot that beats it every time?
What to look for
- Rival armies, racers or soldiers that act with nobody at the controls
- A difficulty setting chosen before the match
- A rival leader's name and portrait in the HUD
- Enemy forces arriving out of the fog of war
Parts
- Knowledge: The AI's working picture of the game world: current observations, remembered facts, and useful map summaries.
- Decision-making architecture: The structure that turns the AI's knowledge and goals into a next action.
- Strategic layer: The long-horizon part of an opponent that decides what the whole force should become and when it should change course.
- Tactical layer: The middle-horizon part that turns strategic intent into positions, targets and coordinated actions for groups in contact.
- Movement and pathfinding: The systems that turn a chosen destination or formation order into legal, readable motion through the world.
- Difficulty: The challenge envelope around the opponent: how well it plays, what help it receives, how quickly it reacts, and whether the game adjusts the pressure.
- AI personality: A stable pattern of priorities and risks that makes one opponent behave differently from another.
- Legibility: How clearly the player can infer what the AI knows, wants and is about to do from its actions and signals.
- Adaptation: The part that changes an opponent's choices after it observes an opponent, a player or the results of its own plans.
- AI evaluation and tuning: The evidence loop around an opponent: run matches, measure outcomes, observe people, expose reasoning and change parameters.
- Sense, think, act: A repeating cycle in which the AI reads the world, chooses a response and applies it, then observes the changed world.
Catalogue: Genre
- Real-time strategy: Armies and economies on an overhead map, with no turns. The AI commands many units at once and sees only near its own units, so it must scout.
- Turn-based strategy: Players take turns, so the AI can think between moves. One turn can hold orders for dozens of units, so the choices multiply fast. Taking turns is the shared feature, whatever the setting: the AI gets time to think, and one turn can hold a very large number of possible orders.
- Shooter: An opponent in a first-person shooter whose AI must react quickly to player actions. The genre is the surface: an FPS opponent still senses, decides and moves, but its decisions must come faster.
- Racing: Rival drivers on the same track as the player. The AI drives near the limit of grip, and a persona sets each driver's skill. A racing rival is an AI opponent because it competes for the same win under the same rules. The car is only the body it acts through.
- Board game: A program across a board, as in chess. Nothing is hidden and nothing is left to chance, so it can search ahead through both sides' moves.
- Simultaneous turns: Every side writes its orders in secret at the same time, then the game reveals and resolves them all together. The AI must commit before it sees the player's orders, just as the player must. It counts as simultaneous when every side commits hidden orders before any are revealed and one resolution applies them all. How the turn ends (a timer, everyone ready, a deadline days away) and the setting do not decide it.
Catalogue: Platform
- Computer program: Code that takes the current game state and returns the AI's next actions. It runs on the player's machine or on a server.
- Board-game automa: A rival made of printed rules and a deck of cards, so one person can play a multiplayer board game alone. The player carries out what the cards say. An automa is an AI opponent with no computer: its decision rules are printed, and the human runs them without making its choices.
Sources
- Kevin Dill, What Is Game AI?, Section 1.1, Introduction
Game AI should be about one thing and one thing only: enabling the developers to create a compelling experience for the player.
- Soren Johnson, Playing to Lose: AI and Civilization (GDC 2008), Talk introduction
I highlighted the difference between “good” AI and “fun” AI and how writing AI for Civ is tricky because it fits somewhere between those two extremes.
- Glen Robertson and Ian Watson, A Review of Real-Time Strategy Game AI, Section 1, Introduction
Video games often have real-time constraints which prevent players from thinking extensively about each action, randomness which prevents players from completely planning future events, and hidden information which prevents players from knowing exactly what the other players are doing.
- David Churchill and Michael Buro, Hierarchical Portfolio Search in Prismata (Game AI Pro 3), Section 30.2, AI Design Goals
This required the creation of several different difficulty settings so that players could continue to be challenged from beginner all the way up to expert play.
- David Churchill and Michael Buro, Hierarchical Portfolio Search in Prismata (Game AI Pro 3), Section 30.2, AI Design Goals
which can become quite boring if the AI does the same thing every time it encounters similar situations.
Use it on your project
teardown-audit: audit my project against the "Game AI" teardown at https://teardownatlas.com/game-ai/
Paste it into a coding agent that has the teardown skills.
Every part
- AI opponent
Flatpack
- Give it senses
- Lay the paths
- Plan against hidden orders
- Choose how it decides
- Fight the battles
- Plan the war
- Give it a character
- Let it learn the player
- Show its intent
- Set the difficulty
- Test and tune
- Seat the opponent
An AI agent wrote this map with the teardown skill. It can contain errors: check the sources before you rely on a part. About and legal