Unit 3
Unit 3
• Hierarchical structure: They often have a hierarchical nature, where more general concepts
(like "animal") are connected to more specific ones (like "dog" or "cat").
• Inheritance: Concepts can inherit properties from more general categories. For example, if
"dog" is connected to "animal" with an "is a" relationship, it might inherit properties such as
"can breathe" from "animal.“
Here, "Rex" inherits properties from the "Dog" frame, but overrides the default color with
"Black" and specifies an owner, "John."
Weak slot and filler structures: Semantic nets, Frames
• Flexibility: Frames are typically more detailed and structured, allowing for complex slot
definitions and procedural attachments, whereas semantic nets provide a more
straightforward, associative form of knowledge representation.
• Use Cases: Semantic nets are often used to model simple associative relationships and
inheritance hierarchies. Frames are used to represent more complex, structured knowledge
such as stereotypes or typical scenarios in reasoning and problem-solving tasks.
Strong slot and filler structures: Conceptual
dependency, Scripts
Strong slot and filler structures are frameworks in artificial intelligence (AI) and knowledge
representation that are more rigid and formal than "weak" slot and filler structures like semantic
nets and frames.
These structures are designed to represent knowledge in a way that facilitates understanding,
reasoning, and inferencing by machines, often in more specific and constrained contexts. Two
common types of strong slot and filler structures are Conceptual Dependency (CD) and
Scripts.
This representation captures the key elements of the action (transfer of possession) and the roles
involved (John as the giver, the book as the object being transferred, and Mary as the recipient).
Strong slot and filler structures: Conceptual
dependency, Scripts
2. Scripts
Scripts are another form of strong slot and filler structure used for knowledge representation,
particularly in natural language understanding. A script represents a stereotypical sequence of
events in a particular context or situation, capturing the typical roles, objects, and actions
involved. Scripts are used to model common scenarios or routines, such as going to a restaurant,
visiting a doctor, or attending a meeting.
Characteristics of Scripts:
• Structured Sequences: Scripts describe a sequence of actions or events that typically occur in
a specific situation.
• Slots and Fillers: Scripts consist of slots that represent the different roles, actions, or events
that can occur within the scenario, and fillers that provide specific details (e.g., the name of the
restaurant, the type of food ordered).
• Default Values: Scripts often include default values or expectations for what normally happens
(e.g., after ordering food, the customer waits for it to be served).
• Causal and Temporal Relations: Scripts capture not just the order of events but also the
causal relationships between them (e.g., you need to order food before it can be served).
Strong slot and filler structures: Conceptual
dependency, Scripts
Example of a Script:
Consider a script for the stereotypical scenario of "Going to a Restaurant":
• Script Name: Restaurant Script
• Slots and Fillers:
• Entry: Customer enters the restaurant.
• Order: Customer orders food from the waiter.
• Payment: Customer pays for the food.
• Exit: Customer leaves the restaurant.
How to Draw the Script:
The script could be visualized as a flowchart showing the sequence of events:
Strong slot and filler structures: Conceptual
dependency, Scripts
This script captures the typical sequence of events that occur when a person goes to a
restaurant, along with the possible variations or alternatives at each step.
Game playing: Evaluation function
Game playing in artificial intelligence (AI) involves developing programs that can play games,
often with the goal of competing against human players or other AI programs. A crucial
component in building these programs is the evaluation function.
2. This can become computationally expensive, especially in games with high branching factors and deep
game trees.
4. Space Complexity:
1. The space complexity is O(b⋅d) as it needs to store the game tree nodes up to depth d.
Minmax Problem
Optimizations for Minimax
1. Alpha-Beta Pruning:
1. A technique to reduce the number of nodes evaluated in the game tree by "pruning" branches that will
not affect the final decision. This allows the Minimax algorithm to run faster by ignoring less promising
branches.
2. Iterative Deepening:
1. Combines depth-first search with increasing depth limits, allowing the search to explore deeper parts of
the game tree progressively.
2. This complexity can become significant for games with large search spaces (like chess).
4. Space Complexity:
1. The space complexity is O(b⋅d) due to the need to store the game tree nodes up to the maximum search
depth.
Example: Simple Two-Player Game
Imagine a game where two players, Player A (Max) and Player B (Min), take turns choosing a
number from a list. The goal for Player A is to maximize the score, while the goal for Player B is to
minimize Player A's score.
Game Setup: Initial list of numbers: [3, 5, 2, 9]
Player A's (Max) Goal: Choose numbers to maximize the score.
Player B's (Min) Goal: Choose numbers to minimize Player A's score.
The decision tree for this game would look something like this:
Example: Simple Two-Player Game
Step-by-Step Explanation
1. Player A (Max) starts.
1. Player A has three choices to start with: 3, 5, or 2. Let's consider one of the branches.
2. Player A picks 3.
2. Player B (Min) chooses next.
1. Remaining choices for Player B are: 5, 2, 9.
2. Player B's strategy is to minimize Player A's score. So, Player B will pick 2, since it's the smallest number
available.
3. Back to Player A (Max).
1. Remaining choices for Player A are: 5, 9.
2. Player A will choose 9 to maximize the score.
4. Evaluating the Total Scores:
1. Player A's total score: 3 (first pick) + 9 (second pick) = 12.
2. Player B's choice forces Player A to end up with the smallest possible maximum score.
Example: Simple Two-Player Game
Calculating Min-Max for All Moves
Now, apply this to all possible moves:
1. If Player A chooses 3:
1. Player B can pick 2 (minimize A's score).
2. Player A then picks 9.
3. Total score for A: 3 + 9 = 12.
2. If Player A chooses 5:
1. Player B can pick 2 (minimize A's score).
2. Player A then picks 9.
3. Total score for A: 5 + 9 = 14.
3. If Player A chooses 2:
1. Player B can pick 3 (next lowest number).
2. Player A then picks 9.
3. Total score for A: 2 + 9 = 11.
Example: Simple Two-Player Game
Optimal Strategy for Player A (Max)
• To maximize the minimum possible score, Player A should choose 5 initially. This ensures that
the worst-case scenario gives a total score of 14, which is higher than the worst-case total
scores if they choose 3 (12) or 2 (11).
Summary
• Player A (Max) starts by selecting the number that gives the highest possible minimum score.
• Player B (Min) responds by selecting the number that minimizes Player A's score.
By using the min-max algorithm, Player A ensures they make the optimal move to maximize
their score, assuming that Player B also plays optimally to minimize Player A's score.
Alpha-beta pruning
Alpha-Beta Pruning is an optimization technique for the Minimax algorithm used in two-
player, zero-sum games (like chess or tic-tac-toe). It reduces the number of nodes evaluated in
the search tree by eliminating branches that cannot affect the final decision. This significantly
speeds up the Minimax search, allowing deeper searches within the same time constraints.
• Alpha (α): The best value (highest score) that the Maximizer (the player trying to maximize the
score) can guarantee at that point or above.
• Beta (β): The best value (lowest score) that the Minimizer (the player trying to minimize the
score) can guarantee at that point or below.
During the search, if the algorithm discovers that a particular branch cannot possibly improve the
current best outcome (either for the Maximizer or Minimizer), it will "prune" or ignore that branch,
reducing the number of nodes it needs to examine.
Alpha-beta pruning
How Alpha-Beta Pruning Works
Alpha-Beta pruning works by maintaining two values, alpha and beta, during the traversal of the Minimax
tree:
1. Alpha (α): Represents the maximum score that the Maximizer can guarantee so far. It starts at
negative infinity and increases as better options are found.
2. Beta (β): Represents the minimum score that the Minimizer can guarantee so far. It starts at positive
infinity and decreases as better options are found.
The Pruning Conditions
• Prune at Max Node (Maximizer's Turn):
• At a Max node (where it is the Maximizer's turn), the search stops and the branch is pruned if the value of any child
node is greater than or equal to β.
• This is because the Minimizer will choose a move that minimizes the score, so if the current score is already worse
than or equal to the best guaranteed option for the Minimizer, there is no point in further exploring that branch.
• Prune at Min Node (Minimizer's Turn):
• At a Min node (where it is the Minimizer's turn), the search stops and the branch is pruned if the value of any child
node is less than or equal to α.
• This is because the Maximizer will choose a move that maximizes the score, so if the current score is already worse
than or equal to the best guaranteed option for the Maximizer, there is no point in further exploring that branch.
Alpha-beta pruning
Benefits of Alpha-Beta Pruning
1. Efficiency:
1. Reduces the number of nodes explored, potentially cutting the search time in half.
2. Allows deeper searches within the same time constraints, improving the quality of decision-making.
2. Optimality:
1. Preserves the optimal decision of the Minimax algorithm.
2. Ensures that no possible winning move is missed while pruning irrelevant branches.
Initial Setup: Alpha (α) starts at -∞ and represents the best value Max can guarantee.
Beta (β) starts at +∞ and represents the best value Min can guarantee.
Example
•Starting at Node A (Max):
•We traverse to B (Min).
•Node B (Min):
•We traverse to D (Max).
•Node D (Max):
•Evaluate the left child of D, which is 3.
•Update α = 3 (best for Max so far).
•Evaluate the right child of D, which is 5.
•Update α = 5 (since 5 > 3).
•Return 5 (Max chooses the best value for itself from D's children).
•Node B (Min):
•We now go to Node E (Max).
•Node E (Max):
•Evaluate the left child of E, which is 6.
•Update α = 6.
•Evaluate the right child of E, which is 9.
•Update α = 9.
•Return 9 (Max chooses 9, the best value for itself from E's children).
Example
Node B (Min):
1. Since it's Min's turn, it chooses the minimum of 5 (from D) and 9 (from E).
2. Return 5 to A (B chooses the minimum value for itself).
In this process, we avoided evaluating some parts of the tree by applying alpha-beta pruning. For
example: After evaluating the value of D (5) for Min at Node B, there was no need to fully evaluate
the right child (9) of Node E. We already knew that Min would not choose a value higher than 5
(because Min's goal is to minimize).
Alpha-Beta Cutoffs
Alpha-Beta cutoffs occur during the Alpha-Beta pruning process in the Minimax algorithm.
When evaluating a game tree for a two-player, zero-sum game, the algorithm uses cutoffs to
eliminate branches that will not influence the final decision. This allows the algorithm to avoid
unnecessary calculations, making it more efficient.
To understand Alpha-Beta cutoffs, let's revisit the two main concepts: Alpha (α) and Beta (β).
• Alpha (α): The maximum score that the Maximizer (the player trying to maximize the score) is
assured of at that point or higher.
• Beta (β): The minimum score that the Minimizer (the player trying to minimize the score) is
assured of at that point or lower.