0% found this document useful (0 votes)
14 views54 pages

AI Unit 3

This document discusses adversarial search methods in artificial intelligence, focusing on game playing concepts such as game trees, minimax algorithms, and alpha-beta pruning. It outlines the structure of game playing, including initial states, player actions, and utility functions, as well as the importance of pruning techniques to optimize search efficiency. Additionally, it touches on constraint satisfaction problems (CSPs) and their applications in various fields, highlighting the role of AI agents in decision-making processes.

Uploaded by

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

AI Unit 3

This document discusses adversarial search methods in artificial intelligence, focusing on game playing concepts such as game trees, minimax algorithms, and alpha-beta pruning. It outlines the structure of game playing, including initial states, player actions, and utility functions, as well as the importance of pruning techniques to optimize search efficiency. Additionally, it touches on constraint satisfaction problems (CSPs) and their applications in various fields, highlighting the role of AI agents in decision-making processes.

Uploaded by

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

21CSC206T– Artificial Intelligence

UNIT – 3
Adversarial search Methods-Game
playing-Important concepts
• Techniques required to get
the best optimal solution
(Choose Algorithms for best
optimal solution within
limited time)
– Pruning: A technique
which allows ignoring the
unwanted portions of a
search tree which make no
difference in its final
result.
– Heuristic Evaluation
Function: It allows to
approximate the cost value
at each level of the search
tree, before reaching the
goal node.
Game playing and knowledge structure-
Elements of Game Playing search
• To play a game, we use a game tree to • For example, in chess, tic-tac-toe, we have
know all the possible choices and to pick two or three possible outcomes. Either to
the best one out. There are following win, to lose, or to draw the match with
elements of a game-playing: values +1,-1 or 0.
• S0: It is the initial state from where a game • Game Tree for Tic-Tac-Toe
begins. – Node: Game states, Edges: Moves taken by
• PLAYER (s): It defines which player is having players
the current turn to make a move in the
state.
• ACTIONS (s): It defines the set of legal
moves to be used in a state.
• RESULT (s, a): It is a transition model which
defines the result of a move.
• TERMINAL-TEST (s): It defines that the
game has ended and returns true.
• UTILITY (s,p): It defines the final value with
which the game has ended. This function is
also known as Objective function or Payoff
function. The price which the winner will
get i.e.
• (-1): If the PLAYER loses.
• (+1): If the PLAYER wins.
• (0): If there is a draw between the PLAYERS.
https://www.tutorialandexample.com/adversarial-search-in-artificial-intelligence/#:~:text=AI%20Adversarial%20search%3A%20A
dversarial%20search,order%20to%20win%20the%20game.
Game playing and knowledge structure-
Elements of Game Playing search
• INITIAL STATE (S0): The top node in
the game-tree represents the initial
state in the tree and shows all the
possible choice to pick out one.
• PLAYER (s): There are two
players, MAX and MIN. MAX begins
the game by picking one best move
and place X in the empty square box.
• ACTIONS (s): Both the players can
make moves in the empty boxes
chance by chance.
• RESULT (s, a): The moves made
by MIN and MAX will decide the
outcome of the game.
• TERMINAL-TEST(s): When all the
empty boxes will be filled, it will be the
terminating state of the game.
• UTILITY: At the end, we will get to
know who wins: MAX or MIN, and
accordingly, the price will be given to
them.
Game as a search problem

• Types of algorithms in Adversarial search


– In a normal search, we follow a sequence of actions to
reach the goal or to finish the game optimally. But in
an adversarial search, the result depends on the
players which will decide the result of the game. It is
also obvious that the solution for the goal state will be
an optimal solution because the player will try to win
the game with the shortest path and under limited
time.
• Minmax Algorithm
• Alpha-beta Pruning
Game Playing vs. Search

• Game vs. search problem

• "Unpredictable" opponent specifying


a move for every possible opponent reply

• Time limits unlikely to find goal, must


approximate
Game Playing

• Formal definition of a game:


– Initial state
– Successor function: returns list of (move,
state) pairs
– Terminal test: determines when game over
Terminal states: states where game ends
– Utility function (objective function or payoff
function): gives numeric value for terminal
states
We will consider games with 2 players (Max and Min);
Max moves first.
Game Tree Example:
Tic-Tac-Toe

Tree from
Max’s
perspective
Minimax Algorithm

• Minimax algorithm
– Perfect play for deterministic, 2-player game
– Max tries to maximize its score
– Min tries to minimize Max’s score (Min)
– Goal: move to position of highest minimax value
Identify best achievable payoff against best play
Minimax Algorithm

Payoff for Max


Minimax Rule

• Goal of game tree search: to determine one move for Max


player that maximizes the guaranteed payoff for a given
game tree for MAX
Regardless of the moves the MIN will take
• The value of each node (Max and MIN) is determined by (back
up from) the values of its children
• MAX plays the worst case scenario:
Always assume MIN to take moves to maximize his pay-off
(i.e., to minimize the pay-off of MAX)
• For a MAX node, the backed up value is the maximum of the
values associated with its children
• For a MIN node, the backed up value is the minimum of the
values associated with its children
Minimax procedure

1. Create start node as a MAX node with current board configuration


2. Expand nodes down to some depth (i.e., ply) of lookahead in the game.
3. Apply the evaluation function at each of the leaf nodes
4. Obtain the “back up" values for each of the non-leaf nodes from its
children by Minimax rule until a value is computed for the root node.
5. Pick the operator associated with the child node whose backed up
value determined the value at the root as the move for MAX
Minimax Search
2

2 1 2 1

2 7 1 8 2 7 1 8 2 7 1 8

This is the move 2


Static evaluator selected by minimax
value
2 1
MAX

MIN
2 7 1 8
Minimax Algorithm (cont’d)

3 9 0 7 2 6

Payoff for Max


Minimax Algorithm (cont’d)

3 0 2

3 9 0 7 2 6

Payoff for Max


Minimax Algorithm (cont’d)

3 0 2

3 9 0 7 2 6

Payoff for Max


Minimax Algorithm (cont’d)

• Properties of minimax algorithm:


• Complete? Yes (if tree is finite)
Optimal? Yes (against an optimal opponent)
Time complexity? O(bm)
m – maximum depth of tree; b branching
• Space
factor complexity? O(bm) (depth-first exploration,
if it generates all successors at once)

m – maximum depth of the tree; b – legal


moves;
Minimax Algorithm

• Limitations
– Not always feasible to traverse entire tree
– Time limitations
• Key Improvement
– Use evaluation function instead of utility
• Evaluation function provides estimate of utility at given
position
α-β Pruning

• Can we improve search by reducing the size of


the game tree to be examined?

Yes!!! Using alpha-beta pruning

Principle
– If a move is determined worse than another move already
examined, then there is no need for further examination of the
node.
α-β Pruning Example
α-β Pruning Example (cont’d)
α-β Pruning Example (cont’d)
α-β Pruning Example (cont’d)
α-β Pruning Example (cont’d)
Alpha-Beta Pruning (αβ prune)

• 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.
Alpha-Beta 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.
Alpha-Beta Pruning Example

1. Search below a MIN 3


node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX ancestor.

2. Search below a MAX
3
node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
3
Alpha-Beta Pruning Example

1. Search below a MIN 3


node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX ancestor.

2. Search below a MAX
3
node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
3 5

β
Alpha-Beta Pruning Example

1. Search below a MIN 3


node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX ancestor.

3 0
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

β
Alpha-Beta Pruning Example

1. Search below a MIN 3


node may be
alpha-pruned if the
beta value is <= to
the alpha value of
some MAX ancestor.

3 0 2
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

β
The α-β algorithm
The α-β algorithm
Another 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.
Example
1. Search below
a MIN node
may be
alpha-pruned
5 if the beta
5 3 value is <= to
the alpha
value of
some MAX
ancestor.
5 3
2. Search
5 6 3 7 below a MAX
α node may be
beta-pruned
if the alpha
value is >= to
the beta
5 6 3 value of
some MIN
5 0 6 1 3 2 4 7 ancestor.
β
Why is it called α-β?

•α 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 β similarly for min


Properties of α-β Prune

• Pruning does not affect final result

• Good move ordering improves effectiveness of


pruning b(e.g., chess, try captures first, then
threats, froward moves, then backward moves…)

• With "perfect ordering," time complexity = O(bm/2)


doubles depth of search that alpha-beta pruning can
explore

Example of the value of reasoning about which


computations are relevant (a form of metareasoning)
What is Game Theory?

• It deals with Bargaining.

• The whole process can be expressed


Mathematically

• Based on Behavior Theory, has a more casual


approach towards study of Human Behavior.

• It also considers how people Interact in Groups.


Constraint satisfactory problem

Constraint Satisfaction Problems (CSP) play a crucial role in


artificial intelligence (AI) as they help solve various problems
that require decision-making under certain constraints. CSPs
represent a class of problems where the goal is to find a solution
that satisfies a set of constraints.
These problems are commonly encountered in fields like
scheduling, planning, resource allocation, and configuration.
Components of CSP
Every CSP can be broken down into three essential components: variables,
domains, and constraints.

Variables: These represent the elements that need to be assigned values. In


a scheduling problem, for instance, each task could be considered a
variable.
Domains: Each variable has a domain, which is the set of possible values it
can take. In the scheduling example, the domain of a task might be the
available time slots.
Constraints: Constraints define the rules that govern the relationships
between variables. In scheduling, constraints might dictate that no two
tasks can overlap or that certain tasks must be completed before others.
CSP applications
• CSPs are widely used across different fields and industries due to their

flexibility and capability of solving real-world problems efficiently. Some

notable applications include:

• Scheduling: CSPs are extensively used in scheduling problems, such as

employee shifts, flight schedules, and course timetabling. The goal is to

allocate tasks or resources while respecting constraints like time,

availability, and precedence.

• Puzzle Solving: Many logic puzzles, such as Sudoku, crosswords, and the

N-Queens problem, can be formulated as CSPs, where the constraints

ensure the puzzle rules are followed.


CSP applications
• Configuration Problems: In product design or software configuration, CSPs
help in choosing the right components or settings based on given
requirements and restrictions. For example, in configuring a computer
system, constraints could specify that certain components are
incompatible with others.
• Robotics and Planning: CSPs are used in pathfinding and task planning for
autonomous agents and robots. For instance, a robot might need to
navigate an environment while avoiding obstacles and minimizing energy
consumption, which can be modeled as a CSP.
• Natural Language Processing (NLP): In NLP, CSPs can be applied to tasks
like sentence parsing, where the goal is to find a valid syntactic structure
based on grammar rules (constraints).
Types of AI agents
1. Simple reflex agents
Simple reflex agents are the simplest agent form that grounds actions on
current perception. This agent does not hold any memory, nor does it interact
with other agents if it is missing information. These agents function on a set
of so-called reflexes or rules. This means that the agent is preprogrammed to
perform actions that correspond to certain conditions being met.
If the agent encounters a situation that it is not prepared for, it cannot
respond appropriately. The agents are only effective in environments that are
fully observable granting access to all necessary information.6
Example: A thermostat that turns on the heating system at a set time every
night. The condition-action rule here is, for instance, if it is 8 PM, then the
heating is activated.
Simplex agents
Model-based reflex agents
Model-based reflex agents use both their current perception and memory to
maintain an internal model of the world. As the agent continues to receive
new information, the model is updated. The agent’s actions depend on its
model, reflexes, previous precepts and current state.
These agents, unlike simple reflex agents, can store information in memory
and can operate in environments that are partially observable and changing.
However, they are still limited by their set of rules.6
Example: A robot vacuum cleaner. As it cleans a dirty room, it senses
obstacles such as furniture and adjusts around them. The robot also stores a
model of the areas it has already cleaned to not get stuck in a loop of
repeated cleaning.
Model-based reflex agents
Goal-based agents
Goal-based agents have an internal model of the world and also a goal or set
of goals. These agents search for action sequences that reach their goal and
plan these actions before acting on them. This search and planning improve
their effectiveness when compared to simple and model-based reflex
agents.7
Example: A navigation system that recommends the fastest route to your
destination. The model considers various routes that reach your destination,
or in other words, your goal. In this example, the agent’s condition-action rule
states that if a quicker route is found, the agent recommends that one
instead.
Goal-based agents
Utility-based agents
Utility-based agents select the sequence of actions that reach the goal and
also maximize utility or reward. Utility is calculated using a utility function.
This function assigns a utility value, a metric measuring the usefulness of an
action or how “happy” it will make the agent, to each scenario based on a set
of fixed criteria.
The criteria can include factors such as progression toward the goal, time
requirements, or computational complexity. The agent then selects the
actions that maximize the expected utility. Hence, these agents are useful in
cases where multiple scenarios achieve a desired goal and an optimal one
must be selected.
Example: A navigation system that recommends the route to your destination
that optimizes fuel efficiency and minimizes the time spent in traffic and the
cost of tolls. This agent measures utility through this set of criteria to select
the most favorable route.
Utility-based agents
Learning agents

Learning agents hold the same capabilities as the other agent types but are
unique in their ability to learn. New experiences are added to their initial
knowledge base, which occurs autonomously. This learning enhances the
agent’s ability to operate in unfamiliar environments. Learning agents may be
utility or goal-based in their reasoning and are comprised of four main
elements:
Learning agents
Learning: This improves the agent’s knowledge by learning from the
environment through its precepts and sensors.
Critic: This provides feedback to the agent on whether the quality of its
responses meets the performance standard.
Performance: This element is responsible for selecting actions upon learning.
Problem generator: This creates various proposals for actions to be taken.
Example: Personalized recommendations on e-commerce sites. These agents
track user activity and preferences in their memory. This information is used
to recommend certain products and services to the user. The cycle repeats
each time new recommendations are made. The user’s activity is
continuously stored for learning purposes. In doing so, the agent improves its
accuracy over time.
Learning agents
Use cases of AI Agents
Customer experience
AI agents can be integrated into websites and apps to enhance the customer
experience by serving as a virtual assistants, providing mental health support,
simulating interviews and other related tasks.
Healthcare
AI agents can be used for various real-world healthcare applications. From
treatment planning for patients in the emergency department to managing
drug processes, these systems save the time and effort of medical
professionals for more urgent tasks.
Emergency response
In case of natural disasters, AI agents can use deep learning algorithms to
retrieve the information of users on social media sites that need rescue.
Benefits of AI Agents
Task automation
With the ongoing advancements in generative AI, there is a
growing interest in workflow optimization using AI, or intelligent
automation. AI agents are AI tools that can automate complex
tasks that would otherwise require human resources.
Greater performance
Multi-agent frameworks tend to outperform singular agents. An
AI agent incorporating knowledge and feedback from other AI
agents specializing in related areas can be useful for information
synthesis.
Quality of responses
AI agents provide responses that are more comprehensive,
accurate and personalized to the user than traditional AI models.

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