Adversarial Search

What are adversarial searches?

Adversarial search is how AI plans when an opponent's moves matter. Learn the basic idea, how minimax and alpha-beta pruning work, and where they are used.

On this page
  1. The short answer
  2. How it differs from ordinary search
  3. The setting
  4. How the program decides
  5. Common methods
  6. Why the search gets hard
  7. Summary

The short answer

Adversarial search is a family of methods AI uses when another agent is working against it. In a game, the program looks ahead at possible moves and replies. It assumes the opponent will choose the reply that is worst for the program, then picks the move that does best under that assumption.

Ordinary search, like finding the shortest route between two cities, has one agent trying to reach a goal. A map doesn’t respond to the route you pick. In adversarial search, the result depends on another decision-maker whose goals conflict with yours. A move that looks strong can fail once the opponent finds a good reply, so the program has to plan for those replies.

The setting

The classic setting has three features:

  • Two players who take turns.
  • Zero-sum results, where one side’s gain is the other side’s loss.
  • Perfect information, where both players can see the full board.

Tic-tac-toe, checkers, chess, and Go fit this setting. Poker does not, because players can’t see each other’s cards.

How the program decides

The program represents the game as a game tree. The root is the current position, each branch is a legal move, and each leaf is a finished game with a score: win, loss, or draw.

Minimax works up from the leaves. On the program’s turn (called MAX), a node takes the highest score among its children. On the opponent’s turn (called MIN), it takes the lowest. The program then chooses the move with the best score at the root.

Here is a simple tic-tac-toe case. The program is playing X, and X has two marks in a row with the third square empty. Filling that square wins the game for X right away. Minimax scores that move as a win, which is the best possible result for X, so the program picks it. It doesn’t need to look any deeper, because no outcome is better than a win.

Common methods

  • Minimax chooses moves in two-player, zero-sum games.
  • Alpha-beta pruning gets the same result as minimax while skipping branches that cannot change the decision.
  • Depth-limited search with an evaluation function handles games too large to search to the end.
  • Expectiminimax handles games with chance, such as dice.

Real-game examples of these methods, from tic-tac-toe to chess and Go, are covered in adversarial search in artificial intelligence examples.

Why the search gets hard

The number of positions grows quickly. Two factors drive this: the branching factor, which is the number of legal moves at each turn, and the depth, which is how many moves ahead the program looks. Tic-tac-toe is small enough to search fully. Chess and Go are far too large to search fully, so programs must cut the search short, estimate positions, or skip branches that don’t matter.

Summary

Adversarial search lets AI choose moves when an opponent’s goals conflict with its own. The program looks ahead through a game tree, assumes the opponent plays its best replies, and uses minimax and related methods to decide.

The complete guide to adversarial search

Adversarial Search in Artificial Intelligence With Examples
Read the guide

Keep exploring

Guides from other topics

All topics →