0% found this document useful (0 votes)
33 views34 pages

Unit 3

Uploaded by

ankurrkt.2005
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)
33 views34 pages

Unit 3

Uploaded by

ankurrkt.2005
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/ 34

Unit 3:Weak slot and filler structures : Semantic nets, Frames

 Weak slot and filler structures are frameworks used in artificial


intelligence (AI) and knowledge representation to model the organization
and processing of knowledge in a structured way.
 These structures are considered "weak" because they offer a flexible and
less formal way to represent knowledge, as opposed to more rigid and
mathematically strict methods like logic-based systems.
 Two of the most common types of weak slot and filler structures are
semantic networks (semantic nets) and frames.
 1. Semantic Nets
 Semantic networks (or semantic nets) are a form of knowledge
representation that uses a graph-based structure to capture relationships
between concepts or objects. In a semantic net:
Weak slot and filler structures: Semantic nets,
Frames
• Nodes represent concepts or objects (e.g., "dog," "mammal," "tail").
• Edges (arcs) represent relationships between the concepts or objects (e.g., "is a," "has,"
"owns").

 Characteristics of Semantic Nets:

• 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.“

• Associative network: Semantic nets emphasize associations between nodes, representing


knowledge as interconnected facts or pieces of information.
Weak slot and filler structures: Semantic
nets, Frames
 Example:
 A simple semantic net could represent the following knowledge:
• "A dog is a mammal."
• "A dog has a tail."
• "John owns a dog."
 This could be visualized as a graph where:
• There is a node for "Dog," "Mammal," "Tail," and "John."
• The "Dog" node is connected to the "Mammal" node with an edge labeled "is a."
• The "Dog" node is connected to the "Tail" node with an edge labeled "has."
• The "John" node is connected to the "Dog" node with an edge labeled "owns."
Weak slot and filler structures: Semantic
nets, Frames
Weak slot and filler structures: Semantic nets, Frames
 2. Frames
 Frames are another structure used for knowledge representation that is designed to capture
stereotypical situations or concepts. A frame is a data structure that represents an object or a
concept along with its associated attributes (slots) and values (fillers).
 Characteristics of Frames:
• Slots and Fillers: Each frame consists of slots that represent attributes or properties, and
each slot has a filler that represents the value of that attribute.
• Slots can be simple properties (like color or size) or more complex (like relations to other frames).
• Fillers can be specific values, ranges, functions, or even other frames.
• Default values: Frames can provide default values for slots, which can be overridden if
specific information is available.
• Inheritance: Similar to semantic nets, frames can be organized in a hierarchy where more
specific frames inherit slots and fillers from more general frames.
• Procedural attachments: Slots can also have associated procedures (called "if-needed" or "if-
added" procedures) that are triggered when a slot value is required or when a new value is
added.
Weak
Weakslot andand
slot fillerfiller
structures: SemanticSemantic
structures: nets, Frames
nets,
 Frames
Example:
 A frame representing the concept of a "dog" might look like this:

 If a specific dog, "Rex," is introduced:

 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

 Key Differences between Semantic Nets and Frames:

• Representation: Semantic nets are graph-based structures that focus on representing


relationships between concepts, while frames are object-based structures that encapsulate
detailed information about a specific concept or situation.

• 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.

 Characteristics of Conceptual Dependency:


• Primitive Actions (ACTs): CD uses a limited set of primitive actions (such as "PTRANS" for
physical transfer, "ATRANS" for abstract transfer, "MTRANS" for mental transfer, etc.) to describe
all possible actions.
• Conceptual Case Roles: Each action is associated with certain roles (like agent, object,
direction, instrument, etc.) that define who or what is involved in the action and how.
• Dependencies: Relationships between actions and entities are captured using dependency links
that specify how actions and entities are connected (e.g., who is performing an action, what is
being acted upon).
Strong slot and filler structures: Conceptual
dependency, Scripts
 Example of Conceptual Dependency:
 Consider the sentence: "John gave a book to Mary."
 In CD, this could be represented as:
• Action: ATRANS (Abstract Transfer)
• Agent: John
• Object: Book
• Recipient: Mary
 The conceptual dependency diagram might look like this:

 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.

 What is an Evaluation Function?


 An evaluation function is a mathematical function used in AI game-playing algorithms to
assess the desirability of a particular game state. The function assigns a numerical value, or
"score," to a game state, representing how favorable that state is for the player making the
move. This score guides the AI in making decisions about which moves to consider or prioritize.

 Key Characteristics of an Evaluation Function:


1. Heuristic-based: Evaluation functions are usually heuristics that provide an approximation of
the actual value or quality of a game state since computing the exact value is often infeasible
due to the complexity of the game.
2. Player-centric: The function is designed to favor one player over the other, meaning it
evaluates states in terms of the advantage or disadvantage to a specific player.
Game playing: Evaluation function
 How Evaluation Functions Work
 1. Components of an Evaluation Function:
 An evaluation function for a game typically considers several features of the game state. For
example, in chess, it might consider:
• Material balance: The total value of pieces each player has on the board.
• Positional factors: Control of key squares, piece activity, pawn structure, etc.
• Mobility: The number of legal moves available to a player.
• King safety: Protection of the king from immediate threats.
 2. Weighted Sum of Features:
 An evaluation function often takes the form of a weighted sum of these features:
Minmax Problem
 The Minimax problem is a decision-making strategy commonly used in game theory and artificial
intelligence, particularly for two-player, zero-sum games. The objective of the Minimax strategy is to
minimize the possible loss for a worst-case scenario. When dealing with gains, it maximizes the
minimum gain (hence "Minimax").
 What is the Minimax Algorithm?
 The Minimax algorithm is a recursive method used to determine the optimal move for a player,
assuming that both players will play optimally. It is widely used in AI for games like chess, tic-tac-toe,
checkers, and other two-player games where players take turns.
 Key Principles of the Minimax Algorithm:
1. Two Players:
1. Maximizer (Max): The player trying to maximize their score (often the AI or the player we are programming).
2. Minimizer (Min): The opponent trying to minimize the Maximizer’s score (often assumed to play optimally).
2. Zero-Sum Game:
1. The total gain of one player is exactly the total loss of the other player. If one player wins, the other loses an
equivalent amount.
3. Complete Knowledge:
1. The game is deterministic and fully observable, meaning that both players have complete knowledge of the
game state at all times.
Minmax Problem
 Properties of the Minimax Algorithm
1. Optimality:
1. The Minimax algorithm is optimal if both players play perfectly, meaning it guarantees the best possible
outcome for the Maximizer.
2. Completeness:
1. The algorithm is complete for finite game trees, as it will explore all possible moves within the depth
limit.
3. Time Complexity:
1. The time complexity is O(b^d), where:
1. b is the branching factor (the average number of legal moves per position).
2. d is the depth of the game tree being explored.

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.

3. Heuristic Evaluation Functions:


1. For games with large search spaces, using heuristic evaluation functions to estimate the value of non-
terminal nodes allows the algorithm to make decisions without reaching terminal nodes.
The min-max search procedure
 Min-Max Search Procedure
 The Min-Max Search is a decision-making algorithm used in artificial intelligence for two-
player, zero-sum games (like chess, tic-tac-toe, or checkers). The goal of the Min-Max search is
to determine the best possible move for the player currently taking a turn (called the
"Maximizer") assuming that the opponent (called the "Minimizer") will also play optimally.
 The algorithm works by recursively simulating all possible moves and counter-moves,
evaluating the resulting game states, and choosing the move that maximizes the chances of
winning (or minimizes the chance of losing) for the Maximizer.

 Steps in the Min-Max Search Procedure


 Here is a step-by-step explanation of how the Min-Max search procedure works:
1. Construct the Game Tree:
1. The game tree represents all possible moves and outcomes from the current state.
2. The root node represents the current state of the game.
3. Child nodes represent possible moves, alternating between levels representing the Maximizer's and
Minimizer's moves.
The min-max search procedure
 Recursive Exploration of the Game Tree:
• Start at the root node (current state of the game).
• Recursively explore all possible moves for both the Maximizer and Minimizer up to a certain
depth or until a terminal node (end state of the game, such as a win, loss, or draw) is reached.

 Evaluate Terminal Nodes:


• Use an evaluation function to assign a score to each terminal node.
• For example, in a game like tic-tac-toe:
• A win for the Maximizer might be assigned a score of +1.
• A loss for the Maximizer might be assigned a score of -1.
• A draw might be assigned a score of 0.
The min-max search procedure
 Backpropagate Values Up the Tree:
• After evaluating the terminal nodes, propagate these values back up the tree:
• For Min nodes (representing the Minimizer's move), select the minimum score from its child nodes. This
simulates the opponent's strategy of minimizing the Maximizer's score.
• For Max nodes (representing the Maximizer's move), select the maximum score from its child nodes.
This simulates the strategy of maximizing the score for the Maximizer.

 Choose the Optimal Move:


• At the root node (the current state), the optimal move for the Maximizer is the move that leads
to the child node with the highest Min-Max value.
• This move is then executed in the actual game.
The min-max search procedure
 Properties of the Min-Max Search Procedure
1. Optimality:
1. The Min-Max algorithm is optimal if both players play perfectly, ensuring the best possible outcome for
the Maximizer.
2. Completeness:
1. The algorithm is complete for finite games with a limited number of moves, as it explores all possible
game states up to a certain depth.
3. Time Complexity:
1. The time complexity is O(b^d), where:
1. b is the branching factor (the average number of legal moves per position).
2. d is the depth of the game tree being explored.

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.

 What is Alpha-Beta Pruning?


 Alpha-Beta pruning is a method that "prunes" or cuts off parts of the search tree that do not
need to be explored because they cannot influence the final decision. It does this by keeping
track of two values:

• 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.

 Best-Case and Worst-Case Performance


• Best Case: The pruning achieves its maximum efficiency when the best moves are always
considered first, leading to a reduction in the search tree size to O(bd/2) instead of O(b^d).
• This is called the perfect ordering scenario.
• Worst Case: If the moves are not ordered optimally, Alpha-Beta pruning may still explore almost
all nodes in the tree, resulting in a complexity O(b^d) ,similar to the standard Minimax algorithm.
Example
 Consider a simple two-player game (Player A and Player B) represented by the following game
tree. Player A (Max) tries to maximize the score, and Player B (Min) tries to minimize it. Each
node in the tree represents a possible game state, and the leaves represent the final score of
that state.

 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).

Node A (Max): Go to Node C (Min).


Node C (Min): Traverse to Node F (Max).
Node F (Max): Evaluate the left child of F, which is 1.Update α = 1.
Evaluate the right child of F, which is 2. Update α = 2.
Return 2 (Max chooses the best value for itself from F's children).

Node C (Min): Now, traverse to Node G (Max).


Node G (Max): Evaluate the left child of G, which is 0.Update α = 0.
Evaluate the right child of G, which is -1.Since -1 < 0, no update to α (Max would not pick -1).
Return 0 (Max chooses 0, the best value for itself from G's children).
Example
 Node C (Min):
• Since it's Min's turn, it chooses the minimum of 2 (from F) and 0 (from G).
• Return 0 to A (C chooses the minimum value for itself).
 Final Decision:
• At Node A (Max):
• Max chooses the maximum of 5 (from B) and 0 (from C).
• Max selects 5.

 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.

 What Are Alpha-Beta Cutoffs?


 Alpha-Beta cutoffs occur when the algorithm determines that further exploration of a particular
branch cannot affect the final decision because it will not improve the current best guaranteed
outcomes (either for the Maximizer or the Minimizer). When such a situation is identified, the
algorithm "cuts off" the remaining branches from further consideration.
Alpha-Beta Cutoffs
 How Alpha-Beta Cutoffs Work

1. Pruning at a Max Node:


1. At a Max node (where it's the Maximizer's turn), the node is pruned (cut off) if the current value of the
node is greater than or equal to Beta (β).
2. Why? The Minimizer has already found a better or equally good option elsewhere, so there's no need to
continue exploring this branch.

2. Pruning at a Min Node:


1. At a Min node (where it's the Minimizer's turn), the node is pruned if the current value of the node is less
than or equal to Alpha (α).
2. Why? The Maximizer has already found a better or equally good option elsewhere, so further exploration
of this branch is unnecessary.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy