Articles / AI · Part 28

Adversarial Search and Optimal Decisions in Artificial Intelligence

Learn how adversarial search helps AI make decisions against intelligent opponents. Explore game trees, Minimax, Alpha-Beta Pruning, evaluation functions, Expectiminimax, and Monte Carlo Tree Search.

Adversarial Search and Optimal Decisions in Artificial Intelligence

Imagine playing chess against a strong opponent.

You cannot simply choose the move that looks best at the moment. You must consider what your opponent might do next, how you could respond, and what opportunities might appear several moves later.

Your opponent is thinking about the same thing.

This makes the problem more complicated than ordinary search. Both players are trying to achieve their own objectives, and each player’s decisions affect the possibilities available to the other.

Artificial Intelligence deals with such situations through a technique called Adversarial Search.

It helps an AI system make decisions while considering the possible actions of an opponent. It is an important foundation of game-playing AI and strategic decision-making.

Adversarial Search is a search technique used in environments where multiple agents have conflicting goals.

Unlike ordinary search, where an agent usually tries to find a path from an initial state to a goal, adversarial search must account for another agent actively trying to prevent it from succeeding.

For example:

  • In chess, one player tries to checkmate the opponent.
  • In checkers, both players try to capture or block the opponent’s pieces.
  • In a strategy game, one player may try to protect a territory while another tries to capture it.

The AI cannot make decisions by considering only its own actions. It must also predict the opponent’s possible responses.

In simple terms, adversarial search means choosing an action while thinking about how an opponent may respond.

2. Why Is Adversarial Search Important?

Consider a chess-playing AI.

Suppose it has three possible moves:

  • Move A gives an immediate advantage.
  • Move B looks less attractive but protects an important piece.
  • Move C creates an opportunity to attack later.

If the AI considers only the immediate result, it might select Move A.

But what if the opponent can respond to Move A with a move that causes the AI to lose its queen?

A good AI should consider that possibility before making its decision.

This is why adversarial search looks beyond the immediate action.

It considers a sequence of decisions made by both players.

3. Understanding the Game Tree

Adversarial search commonly represents possible game situations using a structure called a game tree.

A game tree shows the possible moves from a current position and the positions that may follow them.

Its main components are:

  • Root node: The current game position.
  • Branches: Possible actions or moves.
  • Child nodes: Game positions reached after an action.
  • Terminal nodes: Positions where the game ends.
  • Utility values: Scores representing the outcome for a player.

Consider a simple example:

                    MAX
                   /   \
                  A     B
                 / \   / \
                3   5 2   9

Here, MAX represents the AI player, which wants the highest score. MIN represents the opponent, which wants the lowest score.

The AI must consider both players’ decisions before choosing its move.

This leads us to one of the most important algorithms in adversarial search: Minimax.

4. Minimax: Choosing the Best Decision

The Minimax algorithm assumes that both players make the best decisions available to them.

It works by considering the possible outcomes of moves and selecting the action that gives the AI the best result against an intelligent opponent.

There are two types of players:

MAX player: Tries to maximise the utility value.

MIN player: Tries to minimise the utility value.

The algorithm evaluates the game tree from the bottom upwards.

For example:

                    MAX
                   /   \
                  A     B
                 / \   / \
                3   5 2   9

At each MIN node:

\[
A = \min(3,5)=3
\]

\[
B = \min(2,9)=2
\]

MAX then chooses the larger value:

\[
\max(3,2)=3
\]

Therefore, the best decision for MAX is A.

The algorithm assumes that the opponent will also choose the move that is best for them.

For a detailed explanation, see Article 25: Minimax Algorithm in Artificial Intelligence.

5. Improving Search with Alpha-Beta Pruning

As the number of possible moves increases, the game tree can become extremely large.

Exploring every possible sequence may require too much time and computational power.

Alpha-Beta Pruning improves the efficiency of Minimax by skipping branches that cannot affect the final decision.

It uses two values:

  • Alpha (α): The best value MAX can guarantee so far.
  • Beta (β): The best value MIN can guarantee so far.

When:

\[
\alpha \geq \beta
\]

the algorithm can stop exploring the remaining branches at that point.

The important thing is that Alpha-Beta Pruning does not change the Minimax result. It reduces the number of nodes that need to be examined.

For a complete example and Python implementation, see Article 26: Alpha-Beta Pruning.

6. What Makes a Decision Optimal?

An optimal decision is one that produces the best possible outcome according to the assumptions and information available to the decision-maker.

In adversarial search, the AI must consider the opponent’s best possible responses.

For a two-player, zero-sum game, one player’s gain corresponds to the other player’s loss.

The Minimax algorithm selects a move that maximises the minimum outcome the AI can guarantee.

However, optimal decisions depend on several conditions:

1. Correct game model

The AI must understand the rules, possible actions, and consequences of moves.

2. Accurate utility function

The system needs a way to evaluate the outcomes of different game positions.

3. Opponent modelling

The algorithm must account for the opponent’s possible decisions. Standard Minimax assumes an optimal opponent.

4. Sufficient search

The AI must examine enough future possibilities to make a meaningful decision.

If the search is limited, the system may not discover important consequences that occur several moves later.

Some games have enormous search spaces.

For example, chess has so many possible move sequences that examining every possible game until its end is generally impractical.

Instead, AI systems often search only up to a certain depth.

At that point, they use an evaluation function to estimate how favourable a position is.

An evaluation function may consider:

  • Number and value of remaining pieces.
  • Control of important positions.
  • King safety.
  • Available opportunities for attack.
  • Overall board position.

For example, a simplified chess evaluation function might assign values to pieces:

Chess piece Example value
Pawn 1
Knight 3
Bishop 3
Rook 5
Queen 9

These values provide a basic way to compare positions. Real chess engines use much more sophisticated evaluation methods.

An evaluation function does not necessarily tell us the exact outcome of a game. It estimates how favourable the current position is.

This allows the AI to make decisions without exploring every possible move until the game ends.

8. Other Approaches to Adversarial Decision-Making

Minimax and Alpha-Beta Pruning are important, but they are not the only approaches used in game-playing AI.

A. Expectiminimax

What happens when a game includes randomness?

Consider a board game where a player rolls a dice before moving. The outcome is not controlled entirely by either player.

Expectiminimax extends Minimax by introducing chance nodes.

It considers three types of nodes:

  • MAX nodes: Choose the highest value.
  • MIN nodes: Choose the lowest value.
  • Chance nodes: Calculate an expected value based on possible random outcomes and their probabilities.

The expected value is calculated using:

\[
EV = \sum_{i=1}^{n} P_i V_i
\]

Where:

  • \(P_i\) is the probability of an outcome.
  • \(V_i\) is the value of that outcome.

This approach is useful in games involving dice, random events, or other probabilistic outcomes.

B. Monte Carlo Tree Search (MCTS)

Monte Carlo Tree Search is another important approach used in game-playing AI.

Instead of relying only on a traditional evaluation function, it explores possible moves through repeated simulations.

Its main stages are:

  1. Selection: Select a promising node in the search tree.
  2. Expansion: Add a new possible move.
  3. Simulation: Play out a simulated game from that position.
  4. Backpropagation: Update the results along the path.

By repeating this process, the algorithm gathers information about which moves are likely to produce better outcomes.

MCTS became particularly well known through AlphaGo, the AI system that defeated world champion Lee Sedol in 2016.

Adversarial search is useful beyond traditional board games.

Chess and checkers: AI systems consider possible moves and opponent responses.

Strategy games: Game-playing agents plan attacks, protect resources, and anticipate opponents.

Competitive video games: AI opponents can evaluate possible actions and respond to player strategies.

Robotics and multi-agent systems: Multiple agents may have competing objectives and need to anticipate one another’s actions.

Cybersecurity research: Game-theoretic models can help researchers study interactions between attackers and defenders. These models are not necessarily implemented as ordinary game-tree searches.

Although adversarial search is powerful, it has several challenges.

Large search spaces: The number of possible game states can grow rapidly as search depth increases.

Computational cost: Exploring many possible decisions requires time and processing power.

Imperfect information: Standard Minimax works most naturally when the game state and available actions are known. Games involving hidden cards or private information require additional modelling.

Unpredictable opponents: Real opponents may not always make optimal decisions.

Evaluation difficulty: Estimating the value of a game position can be difficult, especially when the consequences of a move appear much later.

Researchers continue to develop more efficient algorithms and evaluation techniques to address these problems.

Conclusion

Adversarial search allows Artificial Intelligence to make decisions in environments where another agent is actively working towards a conflicting objective.

Instead of considering only its own moves, the AI examines possible responses and tries to choose an action that remains favourable against an intelligent opponent.

Minimax provides the foundation for this process, Alpha-Beta Pruning makes the search more efficient, and approaches such as Expectiminimax and Monte Carlo Tree Search extend decision-making to more complex situations.

The central idea is simple:

A good decision is not just about what you can do next. It is also about what might happen after you do it.

This completes Unit 2: Search Algorithms. We now move towards another important area of Artificial Intelligence: Expert Systems and Fuzzy Logic.


Next Article: Introduction to Expert Systems

Quick quiz

5 questions
What is the main purpose of adversarial search?
What does the MAX player try to do in Minimax?
What is an evaluation function used for?
Which algorithm handles random outcomes using chance nodes?
What are the four main stages of Monte Carlo Tree Search?

Keep a copy

Read offline as a printout or PDF.

farhanpaal.com

Keep reading

AI · Part 6

Agents and Environments.

Understand how AI agents interact with their environments through sensors and actuators. Learn about percepts, percept sequences, agent functions, agent programs, and…

9 min read
AI · Part 8

Rationality and the Concept of a Rational Agent.

Understand rationality in Artificial Intelligence and how rational agents select actions using performance measures, percept sequences, built-in knowledge, and available information.

8 min read

Ask Farhan

Ask anything about Farhan