4: Adversarial Search
Adversarial search deals with scenarios where agents face competition, requiring strategies that anticipate and counteract the actions of opponents. These are often modeled as games, where one agent's gain is another's loss.

4.1 Game Environments
4.1.1 Characteristics of Game Environments
Deterministic vs. Stochastic: Games like chess are deterministic, while games involving dice rolls are stochastic.
Perfect vs. Imperfect Information: Chess has perfect information (all moves are visible), whereas poker involves hidden cards.
Zero-Sum Games: The gain of one player equals the loss of the other.
4.1.2 Types of Games
Two-Player Zero-Sum Games: Common examples include chess, checkers, and tic-tac-toe.
Non-Zero-Sum Games: Cooperative or competitive games where outcomes can benefit multiple players.
Stochastic Games: Games involving randomness, such as backgammon.
4.2 Minimax Algorithm
The Minimax algorithm is a foundational method for decision-making in adversarial games. It evaluates moves by minimizing the maximum possible loss (hence "minimax").
4.2.1 How Minimax Works
Tree Construction: The game is represented as a tree, with nodes corresponding to game states and branches as possible moves.
Leaf Nodes: Represent terminal states, where outcomes are evaluated.
Backtracking Values: Values are propagated backward, with:
The maximizing player choosing the highest value.
The minimizing player choosing the lowest value.
4.2.2 Example: Tic-Tac-Toe
The agent evaluates all possible moves up to the terminal state.
For each terminal state, it assigns a utility value (e.g., +1 for a win, -1 for a loss, 0 for a draw).
Backtracking ensures the optimal move is selected for both players.
4.2.3 Properties of Minimax
Optimality: Guarantees an optimal move if both players act rationally.
Complexity:
Time Complexity: O(b^m), where b is the branching factor, and m is the depth of the game tree.
Space Complexity: O(b * m) for depth-first search traversal.
4.3 Alpha-Beta Pruning
Alpha-beta pruning improves the efficiency of Minimax by eliminating branches that cannot affect the final decision.
4.3.1 Key Concepts
Alpha: The best value the maximizing player can guarantee.
Beta: The best value the minimizing player can guarantee.
Pruning: Skipping unnecessary branches when alpha >= beta.
4.3.2 Example
In chess, if one move guarantees a win for the maximizing player, further exploration of other branches becomes redundant.
4.3.3 Properties of Alpha-Beta Pruning
Effectiveness: Reduces the number of nodes evaluated, allowing deeper exploration within the same time frame.
Complexity:
Best Case: O(b^(m/2)), effectively doubling the depth explored.
Worst Case: Same as Minimax, O(b^m).
4.4 Stochastic Games
Stochastic games introduce randomness into the environment, requiring agents to consider probabilities in decision-making.
4.4.1 Expectimax Algorithm
Used in games like backgammon, Expectimax incorporates chance nodes into the game tree:
Max Nodes: The agent chooses the move with the maximum value.
Chance Nodes: The expected value is calculated based on probabilities.
4.4.2 Example
In backgammon, dice rolls introduce randomness. Expectimax evaluates moves by considering all possible rolls and their probabilities.
4.5 Real-World Applications of Adversarial Search
4.5.1 Strategy Games
Adversarial search powers AI in games like chess, Go, and StarCraft. Notable examples include:
Deep Blue: Defeated chess champion Garry Kasparov using Minimax and alpha-beta pruning.
AlphaGo: Combined search techniques with deep learning to master Go.
4.5.2 Autonomous Driving
Adversarial models are used to simulate interactions between vehicles, predicting the behavior of other drivers to avoid collisions.
4.5.3 Cybersecurity
AI systems defend against adversarial agents in cybersecurity by anticipating attacks and countering them effectively.
4.6 Summary
In this chapter, we explored:
The structure and characteristics of adversarial environments.
The Minimax algorithm and its optimization through alpha-beta pruning.
Handling stochastic games with Expectimax.
Real-world applications in gaming, driving, and cybersecurity.
Last updated