You are on page 1of 61

CLASS OF 2022/2023

Artificial Intelligence
Problem Solving and Search Strategies

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 1
CLASS OF 2022/2023

This lectures summary



Our talk today
 Introduction to Games as search problems
 Minimax tree
 α-β Pruning
 Adversarial Search Heuristics
 Adversarial Search Strategies for Games with Unknown
Tree Depths
 Application of Games Search

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 2
CLASS OF 2022/2023

Introduction to Games as search problems


• Games, also known as Adversarial search or competitive search, is a
subfield of artificial intelligence focused on decision-making in
competitive or adversarial environments.

• It involves the development and application of algorithms and


techniques to make strategic decisions while considering the actions
and intentions of opponents or adversaries.

• The primary goal is to devise strategies that maximize utility or payoff,


taking into account both short-term gains and long-term objectives, in
the face of opposition or uncertainty.
.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 3
CLASS OF 2022/2023

Introduction to Games as search problems


• Concept or idea
─ Competitive Environments: The algorithms are employed in environments
where multiple agents or players compete to achieve conflicting objectives.
Examples include board games, sports competitions, cybersecurity, and
financial markets.
─ Strategic Decision-Making: The algorithms enable agents to make
strategic decisions by analyzing the possible actions of opponents,
predicting their responses and selecting optimal actions to achieve desired
outcomes.
─ Game Theory: Adversarial search is closely related to game theory, a
branch of mathematics and economics that studies interactions between
rational decision-makers. Game theory provides theoretical foundations for
understanding strategic interactions and optimal decision-making in
competitive environments.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 4
CLASS OF 2022/2023

Introduction to Games as search problems


• Importance in Competitive Environments
─ Strategic Decision-Making: In competitive settings, strategic decision-making
is essential for achieving favorable outcomes and outmaneuvering opponents.
Adversarial search enables agents to analyze the potential consequences of
their actions, predict opponent responses, and select optimal strategies to
achieve their goals.
─ Optimal Resource Allocation: Adversarial search algorithms help agents
allocate resources efficiently by identifying opportunities for maximizing utility
while minimizing risks and vulnerabilities. By considering the actions and
behaviors of opponents, agents can make informed decisions about resource
allocation to gain a competitive advantage.
─ Adaptation to Changing Conditions: Competitive environments are dynamic
and uncertain, requiring agents to adapt their strategies in response to evolving
circumstances and opponent behaviors. Adversarial search provides a
framework for continuous learning and adaptation, allowing agents to adjust
their tactics and respond effectively to new challenges and opportunities.
─ Risk Management: Adversarial search enables agents to assess and mitigate
risks by analyzing potential threats and adverse outcomes. By anticipating
opponent actions and formulating contingency plans, agents can minimize the
likelihood
Presenter: Thomas of undesirable
Artificial outcomes
Intelligence and maintain
(AI) and Problem a competitive
Solving and edge
Search Strategies in 5volatile
Slide
CLASS OF 2022/2023

Introduction to Games as search problems


• Goals of Adversarial Search:
─ Maximize Utility: Adversarial search aims to maximize the utility or payoff
of decisions made in competitive environments, considering both short-term
gains and long-term strategic objectives.
─ Minimize Risk: Adversarial search algorithms seek to minimize risks and
vulnerabilities by anticipating and mitigating potential threats and adverse
outcomes.
─ Adapt to Opponents: Adversarial search enables agents to adapt their
strategies and tactics in response to the actions and behaviors of
opponents, maintaining a competitive edge in dynamic environments.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 6
CLASS OF 2022/2023

Introduction to Minimax alogroithm


• Overview of Minimax algorithm
─ The Minimax algorithm is a fundamental strategy in adversarial
search, particularly in two-player zero-sum games such as Chess,
Checkers, and Tic-Tac-Toe.
─ It is designed to determine the optimal move for a player by
considering all possible future states of the game and selecting the
move that maximizes gains while minimizing losses.
─ Here's an expanded explanation of the basic concept and its
application:
1. idea is to simulate the game tree up to a certain depth
2. evaluate the utility of each leaf node (terminal state)
3. propagate the values back up the tree to determine the best
move for the current player.
─ Assumption ………………
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 7
CLASS OF 2022/2023

Introduction to Minimax alogorithm


• Overview of Minimax algorithm
─ Assumption
 both players play optimally, with one player aiming to maximize
their utility (Max player) and the other aiming to minimize it (Min
player).
 At each level of the game tree, the Max player selects moves
that lead to states with the highest utility (maximum gain), while
the Min player selects moves that lead to states with the lowest
utility (minimum loss).
 The algorithm recursively explores the game tree until reaching
a terminal state, where the utility values are determined based
on the game's rules and conditions.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 8
CLASS OF 2022/2023

Introduction to Minimax algorithm


• Overview of Minimax algorithm
─ Define a general case of a game with two players,
─ Identify players as MAX and M1N,
─ MAX starts, and then each take turn moving until the game is over.
─ At the end of the game, points are awarded to the winning player.
─ Definition of terms
 The initial state, which includes the board position and an indication of
whose move it is.
 A set of operators, which define the legal moves that a player can
make.
 A terminal test, which determines when the game is over. States
where the game has ended are called terminal states.
 A utility function (also called a payoff function), which gives a
numeric value for the outcome of a game. In chess, the outcome is a
win, loss,
Presenter: Thomas or Intelligence
Artificial draw, which we Problem
(AI) and can represent
Solving andby the Strategies
Search values +1,Slide—1,
9 or 0
CLASS OF 2022/2023

Introduction to Minimax algorithm


• Overview of Minimax algorithm
─ The figure in the following slide shows part of the search tree for the
game of Tic-Tac-Toe.
 From the initial state, has a choice of nine possible moves. Play
alternates between MAX placing x's and MIN placing o's until we reach
leaf nodes corresponding to terminal states: states where one player
has three in a row or all the squares are filled.
 The number on each leaf node indicates the utility value of the terminal
state from the point of view of MAX; high values are assumed to be
good for MAX and bad for MIN. It is MAX'S job to use the search tree
to determine the best move.
 Even a simple game like Tic-Tac-Toe is too complex to show the whole
search tree. Let’s switch to the absolutely trivial Minmax tree in the Figure at
slide 14. The possible moves “x” for MAX are labeled AI , AT, and AS. The
possible replies “o” for MIN are A11, A12, A13, and so on.
 This particular game ends after one move each by MAX and MIN.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 10
CLASS OF 2022/2023

Game tree (2-player, deterministic, turns)

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

The Minimax algorithm


• The Minimax algorithm is designed to determine the optimal strategy for MAX,
and thus to decide what the best first move is.
─ The algorithm consists of five steps; also mentioned in slide 9:
1. Generate the whole game tree, all the way down to the terminal states.
2. Apply the utility function to each terminal state to get its value.
3. Use the utility of the terminal states to determine the utility of the nodes one
level higher up in the search tree.
4. Continue backing up the values from the leaf nodes toward the root, one layer
at a time.
5. Eventually, the backed-up values reach the top of the tree; at that point, MAX
chooses the move that leads to the highest value. In the topmost A node of ,
MAX has a choice of three moves that will lead to states with utility 3, 2, and
2, respectively.
─ Thus, MAX's best opening move is A1. This is called the Minmax decision,
because it maximizes the utility under the assumption that the opponent will play
perfectly to minimize it.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 13
CLASS OF 2022/2023

The Minimax algorithm


• We define the following
─ Nodes: Nodes in the Minimax tree represent different game states, where
each state corresponds to a specific configuration of the game board or
position. The root node represents the current game state, and its children
nodes represent possible moves or actions that players can take.
─ Levels: Levels in the Minimax tree correspond to the depth of the search and
the alternating turns of the players. The root node is at level 0, and
subsequent levels alternate between maximizing and minimizing players. For
example, at level 1, the maximizing player (e.g., White in Chess) makes a
move, and at level 2, the minimizing player (e.g., Black in Chess) makes a
move in response.
─ Terminal States: Terminal states are leaf nodes in the Minimax tree where
the game ends, either by reaching a win, loss, or draw condition. These states
have no children nodes and represent the final outcomes of the game.
Terminal states have associated utility values, indicating the outcome of the
game (e.g., +1 for a win, -1 for a loss, 0 for a draw) see also slide 10 of this
lecture.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 14
CLASS OF 2022/2023

The Minimax algorithm


• Demonstration of How Minimax Algorithm Traverses the Tree to Find Optimal
Moves
─ Maximizing Player's Turn (Max Nodes): At each level corresponding to the
maximizing player's turn, the Minimax algorithm evaluates all possible moves
(child nodes) and selects the move with the maximum utility value. This
represents the maximizing player's attempt to maximize their gains. The
algorithm recursively explores deeper levels of the tree, evaluating all possible
moves and selecting the maximum value until reaching terminal states.
─ Minimizing Player's Turn (Min Nodes): At each level corresponding to the
minimizing player's turn, the Minimax algorithm evaluates all possible
opponent moves (child nodes) and selects the move with the minimum utility
value. This represents the minimizing player's attempt to minimize losses or
prevent the maximizing player from achieving high gains. The algorithm
continues to traverse deeper levels of the tree, alternating between
maximizing and minimizing players until reaching terminal states.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 15
CLASS OF 2022/2023

The Minimax algorithm


• Demonstration of How Minimax Algorithm Traverses the Tree to Find Optimal
Moves
─ Backpropagation of Values: Once terminal states are reached, the utility
values are propagated back up the tree. At each level, the maximizing player
selects the maximum value from its children nodes, while the minimizing
player selects the minimum value. This process continues until the root node
is reached, where the algorithm selects the optimal move based on the
propagated values.

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)

For chess, b ≈ 35, m ≈100 for "reasonable" games


 exact solution completely infeasible

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

α-β pruning example

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 25
CLASS OF 2022/2023

α-β pruning example

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 26
CLASS OF 2022/2023

α-β pruning example

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 27
CLASS OF 2022/2023

α-β pruning example

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 28
CLASS OF 2022/2023

α-β pruning example

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 29
CLASS OF 2022/2023

α-β pruning pseudocode

• 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

α-β pruning example

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

α-β pruning example

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

α-β pruning example

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

α-β pruning example

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

α-β pruning example

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

 prune that branch


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

Adversarial Search Heuristics


• Overview of Heuristic Evaluation Functions
─ Heuristic evaluation functions are essential components of adversarial search
algorithms. They provide a systematic way to estimate the desirability of game
states without exhaustively exploring the entire search space. These functions
leverage domain-specific knowledge and heuristics to approximate the utility
or value of game positions, guiding decision-making in competitive
environments.

● Importance of Heuristics in Games with Large Search Spaces:


─ In games with large search spaces, such as Chess, Go, and other complex
board games, the number of possible moves and game states is astronomical.
Exhaustively evaluating all possible combinations is computationally
infeasible, making heuristics indispensable for efficient decision-making.
Heuristics enable agents to focus on promising moves and strategies,
effectively reducing the search space and improving search efficiency.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 38
CLASS OF 2022/2023

Adversarial Search Heuristics


• How to make Heuristic Evaluation Functions: consider Text Summarization topic
1. Sentence Importance Scoring:
 Assign a score to each sentence based on its importance in
conveying the main ideas and key information of the text. Factors to
consider may include:
i. Word frequency: Sentences containing important keywords or phrases
that appear frequently throughout the text may be deemed more
important.
ii. Sentence length: Shorter sentences that succinctly convey essential
information may receive higher scores.
iii. Positional importance: Sentences appearing at the beginning or end of
paragraphs, sections, or the document may carry more weight.
iv. Semantic relevance: Sentences that semantically relate to the
document's main topics and themes are likely to be more significant.
v. Named entities: Sentences containing named entities (e.g., people,
organizations, locations) relevant to the text's subject matter may be
considered
Presenter: Thomas Artificialmore important.
Intelligence (AI) and Problem Solving and Search Strategies Slide 39
CLASS OF 2022/2023

Adversarial Search Heuristics


• How to make Heuristic Evaluation Functions: consider Text Summarization topic
2. Content Redundancy: Identify and eliminate redundant or repetitive content to
ensure that the summary captures the essential information concisely.
Redundancy reduction techniques such as duplicate detection or similarity
analysis can help identify and remove redundant sentences.
3. Topic Coverage: Ensure that the summary provides comprehensive
coverage of the main topics and ideas presented in the text. Evaluate the
distribution of topics and themes across sentences and prioritize inclusion of
sentences that represent diverse aspects of the text's content.
4. Grammatical Correctness: Consider grammatical correctness and
coherence of the summary sentences to ensure readability and clarity. Avoid
selecting sentences with grammatical errors or unclear phrasing that may
detract from the overall quality of the summary.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 40
CLASS OF 2022/2023

Adversarial Search Heuristics


• How to make Heuristic Evaluation Functions: consider Text Summarization topic
5. Scalability and Efficiency: Keep in mind the computational complexity of the
heuristic evaluation process, especially when dealing with large documents or
datasets. Optimize the heuristic evaluation criteria and scoring methods to
ensure scalability and efficiency, allowing for timely generation of summaries.
6. Integration with Alpha-Beta Pruning: Integrate the heuristic evaluation scores
into the alpha-beta pruning algorithm to guide the selection of sentences for
inclusion in the summary. Alpha-beta pruning can be used to discard
sentences with low heuristic scores, focusing the summarization process on
sentences deemed most relevant and important based on the heuristic
evaluation criteria.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 41
CLASS OF 2022/2023

Adversarial Search Heuristics


• How to make Heuristic Evaluation Functions: consider Text Summarization topic
as an example and the word frequency:
 Topic: "Natural language processing (NLP) is a field of
artificial intelligence (AI) concerned with the
interaction between computers and humans in natural
language. It enables computers to understand,
interpret, and generate human language in a way that is
both meaningful and useful. NLP techniques are used to
analyze text, extract relevant information, and
facilitate communication between humans and machines.“
 We will calculate the word frequency for each sentence and assign scores
based on the frequency of important keywords. For simplicity, let's focus on the
following keywords: "NLP", "natural language", "computers", "humans",
"intelligence", "interaction", "interpret", "generate".

………Next slide……..

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 42
CLASS OF 2022/2023

Adversarial Search Heuristics


• How to make Heuristic Evaluation Functions: consider Text Summarization topic
as an example and the word frequency:

• 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

Adversarial Search Heuristics


• Let’s repeat the same example and include the other factors: How to make
Heuristic Evaluation Functions: consider Text Summarization topic as an
example and the word frequency, Sentence Length, Semantic Relevance and
Importance Score :

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 44
CLASS OF 2022/2023

Adversarial Search Heuristics


• Let’s repeat the same example and include the other factors: How to make
Heuristic Evaluation Functions: consider Text Summarization topic as an
example and the word frequency, Sentence Length, Semantic Relevance and
Importance Score :
─ Using the preceding slide data, we calculate the overall importance score for
each sentence

Sentence 1: 2 (word frequency) + 3 (sentence length) + 2 (semantic relevance) = 7


Sentence 2: 3 (word frequency) + 4 (sentence length) + 3 (semantic relevance) = 10
Sentence 3: 2 (word frequency) + 4 (sentence length) + 2 (semantic relevance) = 7

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 45
CLASS OF 2022/2023

Adversarial Search Heuristics


• The second example but for a 15 sentences passage. How to make Heuristic
Evaluation Functions: taking Text Summarization topic as an example and the
word frequency, Sentence Length, Semantic Relevance and Importance Score :
• Passage: "Natural language processing (NLP) is a field of artificial
intelligence (AI) concerned with the interaction between computers
and humans in natural language. It enables computers to understand,
interpret, and generate human language in a way that is both
meaningful and useful. NLP techniques are used to analyze text,
extract relevant information, and facilitate communication between
humans and machines. These techniques involve various tasks such as
text classification, sentiment analysis, named entity recognition,
and machine translation. NLP has applications in diverse domains
including healthcare, finance, education, and entertainment. In
healthcare, NLP is used for clinical documentation, patient
monitoring, and medical research. In finance, it helps analyze
market trends, sentiment, and customer feedback. Education benefits
from NLP through automated grading, personalized learning, and
language tutoring. Entertainment industries use NLP for content
recommendation, sentiment analysis of reviews, and script
generation."

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 46
CLASS OF 2022/2023

Adversarial Search Heuristics


• The second example but for a 15 sentences passage. How to make Heuristic
Evaluation Functions: taking Text Summarization topic as an example and the
word frequency, Sentence Length, Semantic Relevance and Importance Score:

These scores indicate the


relative importance of
each sentence based on
word frequency, sentence
length, and semantic
relevance. You can copy
the table for reference.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 47
CLASS OF 2022/2023

Adversarial Search Heuristics


• The second example but for a 15 sentences passage. How to make Heuristic
Evaluation Functions: taking Text Summarization topic as an example and the
word frequency, Sentence Length, Semantic Relevance and Importance Score:
─ Using the preceding slide data, we get the importance score for each sentence
Sentence 1: 5 (word frequency) + 3 (sentence length) + 5 (semantic relevance) = 13
Sentence 2: 4 (word frequency) + 3 (sentence length) + 4 (semantic relevance) = 11
Sentence 3: 3 (word frequency) + 2 (sentence length) + 3 (semantic relevance) = 8
Sentence 4: 3 (word frequency) + 4 (sentence length) + 4 (semantic relevance) = 11
Sentence 5: 4 (word frequency) + 2 (sentence length) + 3 (semantic relevance) = 9
Sentence 6: 2 (word frequency) + 3 (sentence length) + 3 (semantic relevance) = 8
Sentence 7: 3 (word frequency) + 4 (sentence length) + 5 (semantic relevance) = 12
Sentence 8: 2 (word frequency) + 3 (sentence length) + 4 (semantic relevance) = 9
Sentence 9: 3 (word frequency) + 3 (sentence length) + 3 (semantic relevance) = 9
Sentence 10: 4 (word frequency) + 2 (sentence length) + 2 (semantic relevance) = 8
Sentence 11: 3 (word frequency) + 3 (sentence length) + 3 (semantic relevance) = 9
Sentence 12: 2 (word frequency) + 4 (sentence length) + 4 (semantic relevance) = 10
Sentence 13: 3 (word frequency) + 3 (sentence length) + 4 (semantic relevance) = 10
Sentence 14: 2 (word frequency) + 2 (sentence length) + 3 (semantic relevance) = 7
Sentence 15: 4 (word frequency) + 4 (sentence length) + 4 (semantic relevance) = 12

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 48
CLASS OF 2022/2023

Adversarial Search Heuristics


• Let’s take another example for content redundancy and include the other factors:
How to make Heuristic Evaluation Functions: consider Text Summarization topic
as an example and the word frequency, Sentence Length, Semantic Relevance and
Importance Score :
Passage: Natural language processing (NLP) is a field of artificial
intelligence (AI) concerned with the interaction between computers
and humans in natural language. It enables computers to understand,
interpret, and generate human language in a way that is both
meaningful and useful. NLP techniques are used to analyze text,
extract relevant information, and facilitate communication between
humans and machines. These techniques involve various tasks such as
text classification, sentiment analysis, named entity recognition,
and machine translation. NLP has applications in diverse domains
including healthcare, finance, education, and entertainment.

• 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

Adversarial Search Heuristics


• Let’s take another example for content redundancy and include the other factors:
How to make Heuristic Evaluation Functions: consider Text Summarization topic
as an example and the word frequency, Sentence Length, Semantic Relevance and
Importance Score :
─ Assign Scores: Based on the degree of similarity observed between sentence
pairs, assign scores to indicate the level of redundancy. Here's a suggested
scoring scale: High similarity: 4, Medium similarity: 3 and Low similarity: 2
• Some other factor for
heuristic evaluation in this
case may be
1. Identify Common
Information
2. Compare Sentence Pairs
3. Consider Context
4. Use Judgment
5. Iterate and Refine.
Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 50
CLASS OF 2022/2023
Adversarial Search Strategies for Games with
Unknown Tree Depths
• For the game tree with an unknown depth
─ Apply iterative deepening search. It is a search strategy commonly used in
game playing algorithms, particularly in scenarios where the depth of the
search space is unknown. It iteratively performs depth-limited searches,
gradually increasing the depth limit until the goal is found.
─ Benefits in games with unknown search depths:
 In games, especially those with complex or branching game trees, the
depth of the search space may be unknown. Iterative Deepening ensures
a balance between exploration and efficiency. It guarantees that deeper
levels are explored only if necessary, preventing unnecessary
computation.

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

Application of Games Search


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

Application of Games Search


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

Application of Games Search


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

1. Define adversarial search and explain its significance in artificial


intelligence.
2. Describe the Minimax algorithm and its role in adversarial search.
Provide a step-by-step explanation of how Minimax works.
3. Explain how Alpha-Beta Pruning enhances the efficiency of the
Minimax algorithm. Provide pseudocode for Alpha-Beta Pruning
and discuss its benefits.
4. Define the concept of an evaluation function in adversarial search.
5. Explain the role of evaluation functions in guiding decision-making
processes within adversarial search algorithms.
6. Design a heuristic evaluation function for a specific adversarial
game of your choice (e.g., chess, checkers, connect four).

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 59
CLASS OF 2022/2023

Questions

7. Justify the design choices made in your heuristic function,


considering factors such as game rules, state representation, and
strategic goals.
8. Discuss the concept of Iterative Deepening and its application in
games with unknown search depths.
9. Implement the Minimax algorithm in a programming language of
your choice for a simple two-player game (e.g., Tic-Tac-Toe).
Provide code and demonstrate its functionality.
10. Reflect on your understanding of adversarial search and its
implications for decision-making in AI.
11. Discuss how adversarial search techniques can be applied beyond
traditional games to address real-world challenges in various
domains.

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 60
CLASS OF 2022/2023

Questions

12. Implement your designed evaluation function in a programming


language of your choice.
13. Test the functionality of your evaluation function by integrating
it with an existing adversarial search algorithm (e.g., Minimax
with Alpha-Beta Pruning).

Presenter: Thomas Artificial Intelligence (AI) and Problem Solving and Search Strategies Slide 61

You might also like