Lecture 04
Lecture 04
Artificial Intelligence
Problem Solving and Search Strategies
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 1
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 2
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 3
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 4
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 6
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 8
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 11
CLASS OF 2022/2023
Minimax tree
• A Minimax tree is a representation of the game state and all possible
moves that can be made by the players. It demonstrates the decision-
making process in a two-player zero-sum game, such as Chess, Tic-
Tac-Toe, or Checkers.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 12
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 15
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 16
CLASS OF 2022/2023
Minimax Algorithm
Perfect play for deterministic games
Idea: choose move to position with highest
Minmax value = best achievable payoff
against best play
E.g., 2-ply game:
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 17
CLASS OF 2022/2023
Minimax Algorithm
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 18
CLASS OF 2022/2023
Minimax Algorithm with MIN and MAX combined
into one function
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 19
CLASS OF 2022/2023
Minimax Algorithm with MIN and MAX
separated into different functions
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 20
CLASS OF 2022/2023
Properties of Minmax
• Complete? Yes (if tree is finite)
• Optimal? Yes (against an optimal opponent)
• Time complexity? O(bm)
• (m is depth and b is legal move on each point)
Space complexity? O(bm) (depth-first exploration)
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 21
CLASS OF 2022/2023
α-β Pruning
• Overview of Alpha-Beta
─ Alpha-Beta pruning is an optimization technique used in the Minimax
algorithm to reduce the number of nodes evaluated during the search
process. It improves the efficiency of the search by eliminating branches
of the game tree that are guaranteed to be irrelevant to the final decision.
Let's expand on the concept of Alpha-Beta pruning, its application as an
optimization technique for Minimax, and provide pseudocode for its
implementation:
• How it works
1. Minimax Algorithm Complexity: The Minimax algorithm explores the entire
game tree to determine the optimal move for a player. However, this
exhaustive search can become computationally expensive, especially for
games with large branching factors and deep search depths.
2. Pruning Technique: Alpha-Beta pruning aims to mitigate this computational
overhead by selectively pruning branches of the game tree that cannot affect
the final decision. It achieves this by maintaining two values, alpha (α) and
beta (β), representing the best achievable score for the maximizing player and
the minimizing player, respectively.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 22
CLASS OF 2022/2023
α-β Pruning
• Overview of Alpha-Beta
─ Alpha-Beta pruning is an optimization technique used in the Minimax
algorithm to reduce the number of nodes evaluated during the search
process. It improves the efficiency of the search by eliminating branches
of the game tree that are guaranteed to be irrelevant to the final decision.
Let's expand on the concept of Alpha-Beta pruning, its application as an
optimization technique for Minimax, and provide pseudocode for its
implementation:
• How it works
3. Pruning Criteria: During the search, if it is determined that a branch's
utility value cannot improve the current best score for either player, that
branch is pruned. This is based on the observation that the opponent will
never allow the current player to reach that branch, making it irrelevant to
the final decision.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 23
CLASS OF 2022/2023
α-β Pruning
• How it Reduces the Number of Nodes Evaluated
1. Early Termination: Alpha-Beta pruning allows the algorithm to terminate
the evaluation of certain branches early, significantly reducing the number
of nodes visited during the search.
2. Branch Elimination: By pruning irrelevant branches, Alpha-Beta pruning
effectively eliminates large portions of the game tree from consideration,
focusing the search on more promising paths.
3. Improved Efficiency: The reduction in the number of evaluated nodes leads
to a substantial improvement in search efficiency, making it feasible to
apply Minimax to larger game trees and deeper search depths.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 24
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 25
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 26
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 27
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 28
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 29
CLASS OF 2022/2023
• Effect of Alpha-Beta
─ Pruning does not affect final result
─ Good move ordering improves effectiveness of pruning
─ With "perfect ordering," time complexity = O(bm/2)
doubles depth of search that alpha-beta pruning can explore
A simple example of the value of reasoning about which computations are relevant
(a form of metareasoning)
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 30
CLASS OF 2022/2023
α-β Pruning
● Rules of Thumb
─ α is the best ( highest) found so far along the path for Max
─ β is the best (lowest) found so far along the path for Min
─ Search below a MIN node may be alpha-pruned if the its β of some
MAX ancestor
─ Search below a MAX node may be beta-pruned if the its β of some MIN
ancestor.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 31
CLASS OF 2022/2023
1.Search below a
MIN node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX
ancestor.
2. Search below a
MAX node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 32
CLASS OF 2022/2023
1.Search below a 3
MIN node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX
ancestor.
3
2. Search below a
MAX node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor. 3
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 33
CLASS OF 2022/2023
1.Search below a 3
MIN node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX
ancestor.
3
2. Search below a
MAX node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor. 3 5
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 34
CLASS OF 2022/2023
1.Search below a 3
MIN node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX
ancestor. 0
3
2. Search below a
MAX node may be α
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor. 3 5 0
β
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 35
CLASS OF 2022/2023
1.Search below a 3
MIN node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX
ancestor. 0 2
3
2. Search below a
MAX node may be α α
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor. 3 5 0 2
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 36
CLASS OF 2022/2023
Why is it α-β
α is the value of the best
(i.e., highest-value) choice
found so far at any choice
point along the path for
max
If v is worse than α, max
will avoid it
Define β the value of the
best (i.e., lowest-value)
choice we have found so
far at any choice point
along the path for MIN.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 37
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 38
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 40
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 41
CLASS OF 2022/2023
………Next slide……..
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 42
CLASS OF 2022/2023
• Now, we assign scores based on the word frequency count. Let's say we assign a
score of 2 for each occurrence of an important keyword in a sentence.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 43
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 44
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 45
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 46
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 47
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 48
CLASS OF 2022/2023
• Now, let's create a heuristic evaluation for content redundancy. We'll assign scores
based on the similarity of each sentence to other sentences in the passage. A
higher score indicates higher redundancy.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 49
CLASS OF 2022/2023
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 51
CLASS OF 2022/2023
Adversarial Search Strategies for Games with
Unknown Tree Depths
• For the game tree with an unknown depth
─ The following is a pseudocode for the iterative deepening search algorithm as
covered in Lecture 2 and customized for the Minmax algorithm as a Game
search
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 52
CLASS OF 2022/2023
Adversarial Search Strategies for Games with
Unknown Tree Depths
• For the game tree with an unknown depth
─ Below is a pseudocode outlining the integration of the iterative
deepening search algorithm with the Minimax algorithm within the
context of game search. This algorithm utilizes the Minimax function,
its pseudocode of which is provided in the subsequent slide.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 53
CLASS OF 2022/2023
Adversarial Search Strategies for Games with
Unknown Tree Depths
• For the game tree with an unknown depth
─ The pseudocode of the Minimax function, which is invoked by the
iterative deepening function discussed in the preceding slide, is as
follows:
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 54
CLASS OF 2022/2023
In Game alone……….
• Checkers: Chinook ended 40-year-reign of human world champion Marion
Tinsley in 1994. Used a precomputed endgame database defining perfect play for
all positions involving 8 or fewer pieces on the board, a total of 444 billion
positions.
• Chess: Deep Blue defeated human world champion Garry Kasparov in a six-game
match in 1997. Deep Blue searches 200 million positions per second, uses very
sophisticated evaluation, and undisclosed methods for extending some lines of
search up to 40 ply.
• Othello: human champions refuse to compete against computers, who are too
good.
• Go: human champions refuse to compete against computers, who are too bad. In
go, b > 300, so most programs use pattern knowledge bases to suggest plausible
moves.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 55
CLASS OF 2022/2023
Adversarial search/game tree search, is a classical AI technique used
in a wide range of applications where an agent must make decisions in
an environment where other agents are also making decisions with
competing goals. Here are some of the common applications of
adversarial search in AI:
─ Board games: Adversarial search is widely used in board games such as
chess, checkers, and Go, where the agent must plan its moves by
anticipating the opponent's moves and trying to optimize its own score or
win probability.
─ Video games: Adversarial search can be used in video games for
decision-making by non-player characters (NPCs). NPCs can use
adversarial search to plan their actions based on the actions of the human
player or other NPCs.
─ Robotics: Adversarial search techniques enable robots to make strategic
decisions in dynamic and uncertain environments, such as motion planning
and multi-agent coordination.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 56
CLASS OF 2022/2023
Adversarial search, also known as game tree search, is a
classical AI technique used in a wide range of applications where
an agent must make decisions in an environment where other
agents are also making decisions with competing goals. Here are
some of the common applications of adversarial search in AI:
Cybersecurity: Adversarial search can be used to model the
behavior of attackers and defenders in cybersecurity, helping to
identify vulnerabilities and defend against attacks and many other
uses
Medical Diagnosis: Adversarial search can be applied in medical
diagnosis systems to consider various possible diagnoses and
treatment options. The system can iteratively refine its diagnosis by
considering potential diseases and symptoms in an adversarial
manner.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 57
CLASS OF 2022/2023
Adversarial search, also known as game tree search, is a classical AI
technique used in a wide range of applications where an agent must
make decisions in an environment where other agents are also making
decisions with competing goals. Here are some of the common
applications of adversarial search in AI:
Finance: Adversarial search can be used in financial applications, such as
predicting stock prices, where the agent must anticipate the behavior of
other agents in the market
Resource Allocation: Adversarial search algorithms can aid in resource
allocation problems, such as assigning tasks to workers or distributing
resources efficiently in a competitive environment where multiple parties vie
for the same resources.
Overall, adversarial search is a powerful technique that is widely used
in AI applications where agents must make decisions in a competitive
environment, taking into account the actions of other agents.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 58
CLASS OF 2022/2023
Questions
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 59
CLASS OF 2022/2023
Questions
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 60
CLASS OF 2022/2023
Questions
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 61