0% found this document useful (0 votes)
67 views77 pages

Adversarial Search and Game Playing

The document outlines the course on Adversarial Search and Game Playing in Artificial Intelligence, detailing key topics such as game types, game trees, the Minimax algorithm, and Alpha-beta pruning. It explains adversarial search as a method for decision-making in competitive environments, particularly in two-player zero-sum games. Additionally, it covers imperfect real-time decisions and partially observable games, highlighting their characteristics and examples.

Uploaded by

harshil.sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views77 pages

Adversarial Search and Game Playing

The document outlines the course on Adversarial Search and Game Playing in Artificial Intelligence, detailing key topics such as game types, game trees, the Minimax algorithm, and Alpha-beta pruning. It explains adversarial search as a method for decision-making in competitive environments, particularly in two-player zero-sum games. Additionally, it covers imperfect real-time decisions and partially observable games, highlighting their characteristics and examples.

Uploaded by

harshil.sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 77

Course Name: Introduction to Artificial Intelligence

Topic: Adversarial Search and Game playing


Prepared By: Ms. Harshil Sharma, Assistant Professor
Department of FCE
TOPICS TO BE COVERED
 Adversarial Search
 Types of Game
 Formulating a game problem
 Game Tree
 Minmax algorithm
 Alpha-beta pruning
 Imperfect- Real time decisions
 Partially observable games
 State-of-the-art game program
ADVERSARIAL SEARCH

 Adversarial search is a well-suited approach in a competitive


environment, where two or more agents have conflicting goals.
 The adversarial search can be employed in two-player zero-sum
games which means what is good for one player will be the
misfortune for the other. In such a case, there is no win-win outcome.
 Searches in which two or more players with conflicting goals are
trying to explore the same search space for the solution, are
called adversarial searches, often known as Games
ADVERSARIAL SEARCH

Role of Adversarial Search in AI


 Game-playing: The Adversarial search finds a significant application in
game-playing scenarios, including renowned games like chess, Go, and
poker. The adversarial search offers the simplified nature of these games that
represents the state of a game in a straightforward approach and the agents
are limited to a small number of actions whose effects are governed by
precise rules.
 Decision-making: Decision-making plays a central role in adversarial search
algorithms, where the goal is to find the best possible move or strategy for a
player in a competitive environment against one or more components.
TYPES OF GAMES IN AI

 Perfect information: A game with the perfect information is


that in which agents have all the information about the game,
and they can see each other moves also. Examples are Chess,
Checkers, etc.
 Imperfect information: If in a game agents do not have all
information about the game and not aware with what's going
on, such type of games are called the game with imperfect
information, such as Poker, blind search, Battleship etc.
TYPES OF GAMES IN AI
• Deterministic games: Deterministic games are those games which
follow a strict pattern and set of rules for the games, and there is no
randomness associated with them. Examples are chess, Checkers, Go,
tic-tac-toe, etc.
• Non-deterministic games: Non-deterministic are those games which
have various unpredictable events and has a factor of chance or luck.
This factor of chance or luck is introduced by either dice or cards.
These are random, and each action response is not fixed. Such games
are also called as stochastic games.
• Example: Backgammon, Monopoly, Poker, Ludo etc.
TYPES OF GAMES IN AI
Zero-Sum Game
 Zero-sum games are adversarial search which involves pure competition.
 In Zero-sum game each agent's gain or loss of utility is exactly balanced
by the losses or gains of utility of another agent.
 One player of the game try to maximize one single value, while other
player tries to minimize it.
 Each move by one player in the game is called as ply.
 Chess and tic-tac-toe are examples of a Zero-sum game.
 Win =+1, loss=-1, Initially 0
TYPES OF GAMES IN AI

In this topic, we will discuss deterministic games, fully


observable environment, zero-sum, and where each agent
acts alternatively.
FORMALIZATION OF THE GAME PROBLEM:

A game can be formally defined with the following elements:


• S0: The initial state, which specifies how the game is set up at the
start.
• TO-MOVE(s): The player whose turn it is to move in state s.
• ACTIONS(s): The set of legal moves in state s.
• RESULT(s,a): The transition model, which defines the state resulting
from taking action a in state s.
FORMALIZATION OF THE GAME PROBLEM:

• IS-TERMINAL(s): A terminal test, which is true when the


game is over and false otherwise. States where the game has
ended are called terminal states.
• UTILITY(s, p): A utility function (also called an objective
function or payoff function), which defines the final numeric
value to player p when the game ends in terminal state s. In chess,
the outcome is a win, loss, or draw, with values 1, 0, or ½.
GAME TREE:

 A game tree is a tree where nodes of the tree are the game states and
Edges of the tree are the moves by players.
 Game tree involves initial state, action function, and result Function.
GAME TREE:

Example: Tic-Tac-Toe game tree:


The following figure is showing part of the game-tree for tic-tac-toe
game. Following are some key points of the game:
• There are two players MAX and MIN.
• Players have an alternate turn and start with MAX.
• MAX maximizes the result of the game tree
• MIN minimizes the result.
GAME TREE:
GAME TREE:

Example: Tic-Tac-Toe game tree:


The following figure is showing part of the game-tree for tic-tac-toe
game. Following are some key points of the game:
• There are two players MAX and MIN.
• Players have an alternate turn and start with MAX.
• MAX maximizes the result of the game tree
• MIN minimizes the result.
GAME TREE:
• From the initial state, MAX has 9 possible moves as he starts first. MAX place
x and MIN place o, and both player plays alternatively until we reach a leaf
node where one player has three in a row or all squares are filled.
• Both players will compute each node, minimax, the minimax value which is
the best achievable utility against an optimal adversary.
• Suppose both the players are well aware of the tic-tac-toe and playing the
best play. Each player is doing his best to prevent another one from winning.
MIN is acting against Max in the game.
• So in the game tree, we have a layer of Max, a layer of MIN, and each layer is
called as Ply. Max place x, then MIN puts o to prevent Max from winning, and
this game continues until the terminal node.
• In this either MIN wins, MAX wins, or it's a draw. This game-tree is the whole
search space of possibilities that MIN and MAX are playing tic-tac-toe and
taking turns alternately.
OPTIMAL DECISIONS IN GAMES: MINI MAX ALGORITHM
AND ΑLPHA –BETA PRUNING WITH EXAMPLE
 The Minimax algorithm, used in game AI, finds optimal moves
by exploring a game tree, assuming both players play optimally,
while Alpha-Beta pruning optimizes this by eliminating
branches that won't affect the final decision.
MINIMAX ALGORITHM
 The Mini-Max algorithm is a decision-making algorithm used in artificial intelligence,
particularly in game theory and computer games.
 It is designed to minimize the possible loss in a worst-case scenario (hence "min") and
maximize the potential gain (therefore "max").
 In a two-player game, one player is the maximizer, aiming to maximize their score, while
the other is the minimizer, aiming to minimize the maximizer's score.
 The algorithm operates by evaluating all possible moves for both players, predicting the
opponent's responses, and choosing the optimal move to ensure the best possible outcome.
 There are two players MAX and MIN.
 Players have an alternate turn and start with MAX.
 MAX maximizes the result of the game tree
 MIN minimizes the result.
MINIMAX ALGORITHM

 In some games, the word “move” means that both players have taken
an action; therefore the word ply is used to unambiguously mean one
move by one player, bringing us one level deeper in the game tree.
MINIMAX ALGORITHM
MINIMAX ALGORITHM

 Given a game tree, the optimal strategy can be determined by working out the
minimax value of each state in the tree, which we write as MINIMAX(s).
 The minimax value is the utility (for MAX) of being in that state, assuming
that both players play optimally from there to the end of the game.
 The minimax value of a terminal state is just its utility.
 In a non terminal state, MAX prefers to move to a state of maximum value
when it is MAX’s turn to move, and MIN prefers a state of minimum value
(that is, minimum value for MAX and thus maximum value for MIN).
MINIMAX ALGORITHM
MINIMAX ALGORITHM
MINIMAX ALGORITHM
 The minimax algorithm performs a complete depth-first exploration
of the game tree.
 Complete- Min-Max algorithm is Complete. It will definitely find a
solution (if exist), in the finite search tree.
 Optimal- Min-Max algorithm is optimal if both opponents are
playing optimally.
 If the maximum depth of the tree is m and there are b legal moves at
each point, then the time complexity of the minimax algorithm is
O(bm).
 The space complexity is O(bm) for an algorithm that generates all
actions at once, or O(m)
MINIMAX ALGORITHM
MINIMAX ALGORITHM

​Limitations of the Mini-Max Algorithm


Despite its usefulness, the Mini-Max algorithm comes with limitations:
•Computational Complexity
•No Probabilistic Handling
•Exponential Time Complexity
MINIMAX ALGORITHM
Applications of the Mini-Max Algorithm
•Game Theory: It’s extensively used in strategic games like chess,
checkers, and tic-tac-toe.
•AI in Robotics: Mini-Max helps robots make optimal decisions when
faced with adversarial situations.
•Economics: The algorithm is used in decision-making models where
two entities with conflicting goals must make optimal moves.
•Decision-making in AI: Beyond games, Mini-Max is applied in AI
systems that require optimal decision-making in competitive
environments​.
ALPHA – BETA PRUNING ALGORITHM

 Alpha-beta pruning is an optimization technique that improves the


minimax algorithm by cutting off (or “pruning”) branches of the
search tree that don’t need to be explored.
 This reduces the number of nodes the algorithm evaluates, making the
search faster and more efficient while still arriving at the optimal
decision.
ALPHA – BETA PRUNING ALGORITHM

 Alpha-beta pruning enhances the Min-Max algorithm by eliminating


branches that do not affect the final decision.
 The key formulas for alpha-beta pruning are:
ALPHA – BETA PRUNING ALGORITHM

Alpha–beta search updates the values of and as it goes along and prunes
the remaining branches at a node (i.e., terminates the recursive call) as
soon as the value of the current node is known to be worse than the
current or value for MAX or MIN, respectively.
ALPHA – BETA PRUNING ALGORITHM

Condition for Pruning:


Alpha-beta pruning occurs when we find a situation where:
The minimizing player finds a value that is lower than or equal to alpha (β ≤ α). In
this case, there’s no need to explore further because the minimizing player will not
let the maximizing player choose that branch, so we can prune it.
Similarly, the maximizing player can prune a branch when they find a value higher
than or equal to beta (α ≥ β), as the maximizing player will never choose a move
that results in a worse score.
By constantly updating the alpha and beta values as we move through the tree, the
algorithm can prune away branches that are not worth evaluating, thus improving
the efficiency of the search.
ALPHA – BETA PRUNING ALGORITHM

1.The algorithm starts by checking if it has reached a terminal node


or the maximum depth. If so, it returns the heuristic value of that
node.
2.If it’s the maximizing player’s turn, it tries to maximize the score.
For each child node, it updates alpha, and if beta becomes smaller or
equal to alpha, it prunes the rest of the tree.
3.If it’s the minimizing player’s turn, it tries to minimize the score.
Similarly, beta is updated, and if alpha becomes larger or equal to
beta, the algorithm prunes the tree.
ALPHA – BETA PRUNING ALGORITHM

Move Ordering in Alpha-Beta Pruning


 Move ordering plays a crucial role in the efficiency of alpha-beta
pruning.
 It refers to the process of rearranging the moves to be evaluated in such
a way that the best moves are considered first.
 When the optimal moves are evaluated earlier, alpha-beta pruning can
cut off more branches, further reducing the search space and improving
the speed of the algorithm.
ALPHA – BETA PRUNING ALGORITHM

Advantages:
•Faster Computation: Alpha-beta pruning skips unnecessary branches in the
game tree, making decision-making quicker than the standard minimax
algorithm.
•Deeper Search: It allows the algorithm to explore deeper into the game tree
without increasing the time taken, leading to better decision-making.
•Same Optimal Result: The algorithm still finds the best possible move, just
like minimax, but with fewer calculations.
•Works Well for Two-Player Games: It’s effective in games like chess, tic-tac-
toe, and checkers, where both players take turns and try to win.
ALPHA – BETA PRUNING ALGORITHM
Limitations:

Depends on Move Ordering: The algorithm works best if strong moves are evaluated
first. Poor move ordering means fewer branches will be pruned, reducing efficiency.

Not Suitable for All Games: Alpha-beta pruning isn’t helpful in games that involve
chance (like dice games) or incomplete information.

Still Exponential Growth: Even with pruning, game trees can grow very large in
complex games, making it difficult to manage deep searches.

Move Ordering is Challenging: Getting the right move order to maximize pruning is
difficult, and without it, the algorithm’s performance is limited.
ALPHA – BETA PRUNING ALGORITHM
IMPERFECT REAL TIME DECISIONS
ALPHA – BETA PRUNING ALGORITHM

 Imperfect real-time decisions refer to decision-making scenarios


where an AI or player must make a choice quickly under constraints
like limited time, incomplete information, and limited computational
resources.
 The decision made may not be optimal due to these restrictions, hence
"imperfect."
ALPHA – BETA PRUNING ALGORITHM
ALPHA – BETA PRUNING ALGORITHM
ALPHA – BETA PRUNING ALGORITHM
ALPHA – BETA PRUNING ALGORITHM
ALPHA – BETA PRUNING ALGORITHM
ALPHA – BETA PRUNING ALGORITHM
ALPHA – BETA PRUNING ALGORITHM
ALPHA – BETA PRUNING ALGORITHM
PARTIALLY OBSERVABLE GAMES
PARTIALLY OBSERVABLE GAMES

 Partially observable games are games where players have limited or


incomplete information about the current game state.
 Unlike fully observable games like chess, where both players see the
entire board, partially observable games involve hidden elements or
private information, adding a layer of uncertainty.
PARTIALLY OBSERVABLE GAMES

Key Characteristics:
1.Hidden Information: Players do not have complete knowledge of the
game state. For example, in card games like Poker, players cannot see
opponents' cards.
2.Uncertainty: Decisions must be made based on guesses or inferences
rather than complete data.
3.Strategy and Bluffing: These games often require strategic thinking,
deduction, and bluffing.
PARTIALLY OBSERVABLE GAMES

Examples:

 Kriegspiel: A chess variant where players do not see the opponent's


pieces.
 Poker: Where players cannot see each other's cards.
 Battleship: Players guess the location of opponents' ships
KRIEGSPIEL : A PARTIALLY OBSERVABLE CHESS
VARIANT

 Definition: A chess variant where players cannot see the opponent's


pieces.
 Played with a referee who has full visibility of the board. The referee
provides limited feedback like “illegal move” or “capture on square
X.”
 Objective: Achieve checkmate with limited information, making
educated guesses about the opponent's position.
KRIEGSPIEL : A PARTIALLY OBSERVABLE CHESS
VARIANT

a. Belief State in Kriegspiel


 Belief State: A player’s perceived set of all possible game states
based on known moves and referee feedback.
 The belief state evolves with each move, similar to state estimation in
AI.
 Strategies must consider all possible game states within this belief
state.
KRIEGSPIEL : A PARTIALLY OBSERVABLE CHESS
VARIANT

b. Types of Checkmates in Kriegspiel


 Guaranteed Checkmate: A strategy that ensures victory regardless
of the opponent’s actions.
 Probabilistic Checkmate: A strategy that likely leads to success but
may fail due to uncertainty.
 Accidental Checkmate: A checkmate resulting from unintended
consequences, leveraging the opponent’s lack of awareness.
KRIEGSPIEL : A PARTIALLY OBSERVABLE CHESS
VARIANT

c. Strategic Challenges
 Predicting the opponent’s belief state and possible responses.
 Utilizing limited feedback to deduce the opponent’s piece positions.
 Balancing exploration (gathering information) and exploitation
(executing winning strategies).
CARD GAMES: STOCHASTIC PARTIALLY OBSERVABLE
GAMES

Stochastic partially observable games are complex, multi-agent


environments where players make decisions under uncertainty.
These games combine three main features:
1.Stochasticity (Randomness): Events or outcomes are influenced by
random factors.
2.Partial Observability: Players have limited information about the
game state.
3.Multi-Agent Interaction: Multiple players interact, often with
conflicting objectives.
CARD GAMES: STOCHASTIC PARTIALLY OBSERVABLE
GAMES

Examples: Poker, Bridge, where initial card distribution is random and


hidden.
•Unlike Kriegspiel, card games involve a random element and require
risk assessment.
•Strategies often include:
• Bluffing: Creating a false perception of one's hand.
• Inference: Estimating opponents' cards based on their behavior
and betting patterns.
CARD GAMES: STOCHASTIC PARTIALLY OBSERVABLE
GAMES
PARTIALLY OBSERVABLE GAMES

Computational Complexity in Partially Observable Games

 Determining an optimal strategy is complex due to the need for


evaluating all possible belief states.
 AI applications: Developing algorithms for decision-making under
uncertainty, reinforcement learning, and probabilistic reasoning.
 Randomization can be an effective strategy to create unpredictability.
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS

 State-of-the-Art Game Programs refer to advanced computer


programs that showcase the highest level of artificial intelligence (AI)
in mastering complex games.
 These programs are designed to play games at or beyond the level of
top human experts using sophisticated AI techniques like machine
learning, deep learning, and search algorithms.
STATE-OF-THE-ART GAME PROGRAMS

Key Features of State-of-the-Art Game Programs:


1. Advanced Algorithms: They use techniques like alpha-beta pruning,
reinforcement learning, and neural networks.
2. Self-Learning: Many modern programs learn through self-play, where they
improve by playing against themselves.
3. Massive Computation: They process millions of possible game positions
per second.
4. Real-Time Decision Making: Capable of making strategic decisions
quickly, even under uncertain conditions.
STATE-OF-THE-ART GAME PROGRAMS
Examples of State-of-the-Art Game Programs:
1. Deep Blue for Chess: Defeated World Chess Champion Garry Kasparov in
1997. Used brute-force search with alpha-beta pruning.
2. AlphaZero by DeepMind: Learned chess, shogi, and Go through self-play,
achieving superhuman performance.
3. Chinook for Checkers: Solved the game in 2007, ensuring perfect play that
guarantees a draw.
4. TD-Gammon for Backgammon: Reached expert-level play using
Temporal Difference Learning, an early form of reinforcement learning.
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS

 Chinook is a computer program that plays checkers (also known as


draughts).
 It was developed between the years 1989 to 2007 at the University of Alberta
, by a team led by Jonathan Schaeffer and consisting of Rob Lake, Paul Lu,
Martin Bryant, and Norman Treloar.
 The program's algorithms include an opening book which is a library of
opening moves from games played by checkers grandmasters; a deep
search algorithm; a good move evaluation function; and an end-game
database for all positions with eight pieces or fewer.
 All of Chinook's knowledge was programmed by its creators, rather than
learned using an artificial intelligence system.
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
STATE-OF-THE-ART GAME PROGRAMS
REFERENCE BOOK

ArtificialIntelligence: A Modern Approach S.


Russell and P. Norvig Prentice Hall
Thank You!!

You might also like