SlideShare a Scribd company logo
1 of 50
Types of algorithms in Adversarial
search
• Adversarial search is a game-playing technique
where the agents are surrounded by a competitive
environment.
• 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.
• There are following types of adversarial search:
– Min-max Algorithm
– Alpha-beta Pruning.
10/30/2023 1
Department of CSE (AI/ML)
Min-Max Algorithm
• In artificial intelligence, minimax is a decision-
making strategy under game theory, which is used to
minimize the losing chances in a game and to
maximize the winning chances.
• This strategy is also known as ‘Min-max,’ ’MM,’ or
‘Saddle point.’
10/30/2023 2
Department of CSE (AI/ML)
Min-Max Algorithm
• Mini-max algorithm is a recursive or backtracking algorithm
which is used in decision-making and game theory. It provides
an optimal move for the player assuming that opponent is also
playing optimally.
• Mini-Max algorithm uses recursion to search through the
game-tree.
• Example : Chess, Checkers, tic-tac-toe
• In this algorithm two players play the game; one is called
MAX and other is called MIN.
10/30/2023 3
Department of CSE (AI/ML)
Mini-Max Algorithm
• Both the players fight it as the opponent player gets the
minimum benefit while they get the maximum benefit.
• MIN: Decrease the chances of MAX to win the game.
• MAX: Increases his chances of winning the game.
• The minimax algorithm performs a depth-first search
algorithm for the exploration of the complete game tree.
• The minimax algorithm proceeds all the way down to the
terminal node of the tree, then backtrack the tree as the
recursion.
10/30/2023 4
Department of CSE (AI/ML)
Working of Min-Max Algorithm
• MINIMAX algorithm is a backtracking algorithm where it
backtracks to pick the best move out of several choices.
• MINIMAX strategy follows the DFS (Depth-first
search) concept.
• Here, we have two players MIN and MAX, and the game is
played alternatively between them, i.e., when MAX made a
move, then the next turn is of MIN.
• It means the move made by MAX is fixed and, he cannot
change it.
• The same concept is followed in DFS strategy, i.e., we
follow the same path and cannot change in the middle.
• That’s why in MINIMAX algorithm, instead of BFS, we
follow DFS.
10/30/2023 5
Department of CSE (AI/ML)
Working of Min-Max Algorithm
• Keep on generating the game tree/ search tree till a
limit d.
• Compute the move using a heuristic function.
• Propagate the values from the leaf node till the
current position following the minimax strategy.
• Make the best move from the choices.
10/30/2023 6
Department of CSE (AI/ML)
Pseudocode for Minimax Algorithm
10/30/2023 Department of CSE (AI/ML) 7
Step 1
• In the first step, the algorithm generates the
entire game-tree and apply the utility function
to get the utility values for the terminal states.
• In the below tree diagram, let's take A is the
initial state of the tree.
• Suppose maximizer takes first turn which has
worst-case initial value =- infinity, and
minimizer will take next turn which has worst-
case initial value = +infinity.
10/30/2023 Department of CSE (AI/ML) 8
10/30/2023 Department of CSE (AI/ML) 9
Step 2
• Now, first we find the utilities value for the
Maximizer, its initial value is -∞, so we will
compare each value in terminal state with initial
value of Maximizer and determines the higher
nodes values. It will find the maximum among the
all.
• For node D max(-1,- -∞) => max(-1,4)= 4
• For Node E max(2, -∞) => max(2, 6)= 6
• For Node F max(-3, -∞) => max(-3,-5) = -3
• For node G max(0, -∞) = max(0, 7) = 7
10/30/2023 Department of CSE (AI/ML) 10
10/30/2023 Department of CSE (AI/ML) 11
Step 3
• In the next step, it's a turn for minimizer, so it
will compare all nodes value with +∞ and will
find the 3rd layer node values.
• For node B= min(4,6) = 4
• For node C= min (-3, 7) = -3
10/30/2023 Department of CSE (AI/ML) 12
10/30/2023 Department of CSE (AI/ML) 13
Step 4
• Now it's a turn for Maximizer, and it will again
choose the maximum of all nodes value and
find the maximum value for the root node.
• In this game tree, there are only 4 layers, hence
we reach immediately to the root node, but in
real games, there will be more than 4 layers.
• For node A max(4, -3)= 4
10/30/2023 Department of CSE (AI/ML) 14
10/30/2023 Department of CSE (AI/ML) 15
Example 2
10/30/2023 Department of CSE (AI/ML) 16
Solution
10/30/2023 Department of CSE (AI/ML) 17
Limitation of the minimax Algorithm
• The main drawback of the minimax algorithm
is that it gets really slow for complex games
such as Chess, go, etc.
• This type of games has a huge branching
factor, and the player has lots of choices to
decide.
• This limitation of the minimax algorithm can
be improved from alpha-beta pruning.
10/30/2023 Department of CSE (AI/ML) 18
Alpha-Beta Pruning
Exploiting the Fact of an Adversary
• If a position is provably bad:
– It is NO USE expending search time to find out exactly how bad
• If the adversary can force a bad position:
– It is NO USE expending search time to find out the good positions
that the adversary won’t let you achieve anyway
• Bad = not better than we already know we can achieve
elsewhere.
• Contrast normal search:
– ANY node might be a winner.
– ALL nodes must be considered.
– (A* avoids this through knowledge, i.e., heuristics)
Another Alpha-Beta Example
(−∞, +∞)
(−∞,+∞)
Range of possible values
Do DF-search until first leaf
Alpha-Beta Example (continued)
(−∞,3]
(−∞,+∞)
Alpha-Beta Example (continued)
(−∞,3]
(−∞,+∞)
Alpha-Beta Example (continued)
[3,+∞)
[3,3]
Alpha-Beta Example (continued)
(−∞,2]
[3,+∞)
[3,3]
This node is
worse for MAX
Alpha-Beta Example (continued)
(−∞,2]
[3,14]
[3,3] (−∞,14]
,
Alpha-Beta Example (continued)
(−∞,2]
[3,5]
[3,3] (−∞,5]
,
Alpha-Beta Example (continued)
[2,2]
(−∞,2]
[3,3]
[3,3]
Alpha-Beta Example (continued)
[2,2]
(−∞,2]
[3,3]
[3,3]
General alpha-beta pruning
• Consider a node n in the tree
---
• If player has a better choice
at:
– Parent node of n
– Or any choice point further
up
• Then n will never be reached
in play.
• Hence, when that much is
known about n, it can be
pruned.
Alpha-beta Algorithm
• Depth first search
– only considers nodes along a single path from root at any time
a = highest-value choice found at any choice point of path for MAX
(initially, a = −infinity)
b = lowest-value choice found at any choice point of path for MIN
(initially, b = +infinity)
• Pass current values of a and b down to child nodes during search.
• Update values of a and b during search:
– MAX updates a at MAX nodes
– MIN updates b at MIN nodes
• Prune remaining branches at a node when a ≥ b
When to Prune
• Prune whenever a ≥ b.
– Prune below a Max node whose alpha value becomes
greater than or equal to the beta value of its ancestors.
• Max nodes update alpha based on children’s returned values.
– Prune below a Min node whose beta value becomes less
than or equal to the alpha value of its ancestors.
• Min nodes update beta based on children’s returned values.
Alpha-Beta Example Revisited
a, b, initial values
Do DF-search until first leaf
a=−
b =+
a=−
b =+
a, b, passed to kids
Alpha-Beta Example (continued)
MIN updates b, based on kids
a=−
b =+
a=−
b =3
Alpha-Beta Example (continued)
a=−
b =3
MIN updates b, based on kids.
No change.
a=−
b =+
Alpha-Beta Example (continued)
MAX updates a, based on kids.
a=3
b =+
3 is returned
as node value.
Alpha-Beta Example (continued)
a=3
b =+
a=3
b =+
a, b, passed to kids
Alpha-Beta Example (continued)
a=3
b =+
a=3
b =2
MIN updates b,
based on kids.
Alpha-Beta Example (continued)
a=3
b =2
a ≥ b,
so prune.
a=3
b =+
Alpha-Beta Example (continued)
2 is returned
as node value.
MAX updates a, based on kids.
No change. a=3
b =+
Alpha-Beta Example (continued)
,
a=3
b =+
a=3
b =+
a, b, passed to kids
Alpha-Beta Example (continued)
,
a=3
b =14
a=3
b =+
MIN updates b,
based on kids.
Alpha-Beta Example (continued)
,
a=3
b =5
a=3
b =+
MIN updates b,
based on kids.
Alpha-Beta Example (continued)
a=3
b =+ 2 is returned
as node value.
2
Alpha-Beta Example (continued)
Max calculates the same node
value, and makes the same
move!
2
Effectiveness of Alpha-Beta Search
• Worst-Case
– branches are ordered so that no pruning takes place. In this case
alpha-beta gives no improvement over exhaustive search
• Best-Case
– each player’s best move is the left-most child (i.e., evaluated first)
– in practice, performance is closer to best rather than worst-case
– E.g., sort moves by the remembered move values found last time.
– E.g., expand captures first, then threats, then forward moves, etc.
– E.g., run Iterative Deepening search, sort by value last iteration.
• In practice often get O(b(d/2)) rather than O(bd)
– this is the same as having a branching factor of sqrt(b),
• (sqrt(b))d = b(d/2),i.e., we effectively go from b to square root of b
– e.g., in chess go from b ~ 35 to b ~ 6
• this permits much deeper search in the same amount of time
Final Comments about Alpha-Beta Pruning
• Pruning does not affect final results
• Entire subtrees can be pruned.
• Good move ordering improves effectiveness of
pruning
• Repeated states are again possible.
– Store them in memory = transposition table
Example
3 4 1 2 7 8 5 6
-which nodes can be pruned?
Answer to Example
3 4 1 2 7 8 5 6
-which nodes can be pruned?
Answer: NONE! Because the most favorable nodes for both are explored last (i.e., in
the diagram, are on the right-hand side).
Max
Min
Max
Second Example
(the exact mirror image of the first
example)
6 5 8 7 2 1 3 4
-which nodes can be pruned?
Answer to Second Example
(the exact mirror image of the first
example)
6 5 8 7 2 1 3 4
-which nodes can be pruned?
Min
Max
Max
Answer: LOTS! Because the most favorable nodes for both are explored first (i.e., in
the diagram, are on the left-hand side).

More Related Content

What's hot

Dempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th SemDempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th SemDigiGurukul
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchDheerendra k
 
Logical Agents
Logical AgentsLogical Agents
Logical AgentsYasir Khan
 
Deep Learning Frameworks slides
Deep Learning Frameworks slides Deep Learning Frameworks slides
Deep Learning Frameworks slides Sheamus McGovern
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agentsMegha Sharma
 
Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)Falak Chaudry
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic ReasoningJunya Tanaka
 
Machine Learning: Introduction to Neural Networks
Machine Learning: Introduction to Neural NetworksMachine Learning: Introduction to Neural Networks
Machine Learning: Introduction to Neural NetworksFrancesco Collova'
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchNilu Desai
 
Decision tree in artificial intelligence
Decision tree in artificial intelligenceDecision tree in artificial intelligence
Decision tree in artificial intelligenceMdAlAmin187
 
Reinforcement learning, Q-Learning
Reinforcement learning, Q-LearningReinforcement learning, Q-Learning
Reinforcement learning, Q-LearningKuppusamy P
 
Control Strategies in AI
Control Strategies in AI Control Strategies in AI
Control Strategies in AI Bharat Bhushan
 

What's hot (20)

Dempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th SemDempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th Sem
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Expert systems
Expert systemsExpert systems
Expert systems
 
First order logic
First order logicFirst order logic
First order logic
 
Uncertainty in AI
Uncertainty in AIUncertainty in AI
Uncertainty in AI
 
Logical Agents
Logical AgentsLogical Agents
Logical Agents
 
AI Lecture 7 (uncertainty)
AI Lecture 7 (uncertainty)AI Lecture 7 (uncertainty)
AI Lecture 7 (uncertainty)
 
Deep Learning Frameworks slides
Deep Learning Frameworks slides Deep Learning Frameworks slides
Deep Learning Frameworks slides
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agents
 
Rai practical presentations.
Rai practical presentations.Rai practical presentations.
Rai practical presentations.
 
Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)
 
Probabilistic Reasoning
Probabilistic ReasoningProbabilistic Reasoning
Probabilistic Reasoning
 
Machine Learning: Introduction to Neural Networks
Machine Learning: Introduction to Neural NetworksMachine Learning: Introduction to Neural Networks
Machine Learning: Introduction to Neural Networks
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Decision tree in artificial intelligence
Decision tree in artificial intelligenceDecision tree in artificial intelligence
Decision tree in artificial intelligence
 
Reinforcement learning, Q-Learning
Reinforcement learning, Q-LearningReinforcement learning, Q-Learning
Reinforcement learning, Q-Learning
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
 
Control Strategies in AI
Control Strategies in AI Control Strategies in AI
Control Strategies in AI
 

Similar to Minmax and alpha beta pruning.pptx

AI subject - Game Theory and cps ppt pptx
AI subject  - Game Theory and cps ppt pptxAI subject  - Game Theory and cps ppt pptx
AI subject - Game Theory and cps ppt pptxnizmishaik1
 
ch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.pptch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.pptSanGeet25
 
Jarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.gamesJarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.gamesPalGov
 
12 adversal search
12 adversal search12 adversal search
12 adversal searchTianlu Wang
 
Game playing (tic tac-toe), andor graph
Game playing (tic tac-toe), andor graphGame playing (tic tac-toe), andor graph
Game playing (tic tac-toe), andor graphSyed Zaid Irshad
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.pptssuser148ae0
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AIvikas dhakane
 
GamePlaying.ppt
GamePlaying.pptGamePlaying.ppt
GamePlaying.pptVihaanN2
 
Juegos minimax AlfaBeta
Juegos minimax AlfaBetaJuegos minimax AlfaBeta
Juegos minimax AlfaBetanelsonbc20
 
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAsst.prof M.Gokilavani
 

Similar to Minmax and alpha beta pruning.pptx (20)

AI subject - Game Theory and cps ppt pptx
AI subject  - Game Theory and cps ppt pptxAI subject  - Game Theory and cps ppt pptx
AI subject - Game Theory and cps ppt pptx
 
ch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.pptch_5 Game playing Min max and Alpha Beta pruning.ppt
ch_5 Game playing Min max and Alpha Beta pruning.ppt
 
Jarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.gamesJarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.games
 
Capgemini 1
Capgemini 1Capgemini 1
Capgemini 1
 
Alpha beta
Alpha betaAlpha beta
Alpha beta
 
AI_unit3.pptx
AI_unit3.pptxAI_unit3.pptx
AI_unit3.pptx
 
Two player games
Two player gamesTwo player games
Two player games
 
12 adversal search
12 adversal search12 adversal search
12 adversal search
 
Game playing (tic tac-toe), andor graph
Game playing (tic tac-toe), andor graphGame playing (tic tac-toe), andor graph
Game playing (tic tac-toe), andor graph
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
 
Alpha-Beta Search
Alpha-Beta SearchAlpha-Beta Search
Alpha-Beta Search
 
GamePlaying.ppt
GamePlaying.pptGamePlaying.ppt
GamePlaying.ppt
 
AI_Session 14 Min Max Algorithm.pptx
AI_Session 14 Min Max Algorithm.pptxAI_Session 14 Min Max Algorithm.pptx
AI_Session 14 Min Max Algorithm.pptx
 
Games.4
Games.4Games.4
Games.4
 
Juegos minimax AlfaBeta
Juegos minimax AlfaBetaJuegos minimax AlfaBeta
Juegos minimax AlfaBeta
 
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
 
Parallel searching
Parallel searchingParallel searching
Parallel searching
 
Parallel search
Parallel searchParallel search
Parallel search
 
Game playing.ppt
Game playing.pptGame playing.ppt
Game playing.ppt
 

More from PriyadharshiniG41

understanding-cholera-a-comprehensive-analysis.pdf
understanding-cholera-a-comprehensive-analysis.pdfunderstanding-cholera-a-comprehensive-analysis.pdf
understanding-cholera-a-comprehensive-analysis.pdfPriyadharshiniG41
 
combatting-malaria-strategies-for-prevention-and-treatment.pdf
combatting-malaria-strategies-for-prevention-and-treatment.pdfcombatting-malaria-strategies-for-prevention-and-treatment.pdf
combatting-malaria-strategies-for-prevention-and-treatment.pdfPriyadharshiniG41
 
ant colony optimization working and explanation
ant colony optimization working and explanationant colony optimization working and explanation
ant colony optimization working and explanationPriyadharshiniG41
 
RandomForests in artificial intelligence
RandomForests in artificial intelligenceRandomForests in artificial intelligence
RandomForests in artificial intelligencePriyadharshiniG41
 
knowledge representation in artificial intelligence
knowledge representation in artificial intelligenceknowledge representation in artificial intelligence
knowledge representation in artificial intelligencePriyadharshiniG41
 
information retrieval in artificial intelligence
information retrieval in artificial intelligenceinformation retrieval in artificial intelligence
information retrieval in artificial intelligencePriyadharshiniG41
 
Inference rules in artificial intelligence
Inference rules in artificial intelligenceInference rules in artificial intelligence
Inference rules in artificial intelligencePriyadharshiniG41
 
Unit I-Final MArketing analytics unit 1 ppt
Unit I-Final MArketing analytics unit 1 pptUnit I-Final MArketing analytics unit 1 ppt
Unit I-Final MArketing analytics unit 1 pptPriyadharshiniG41
 
agent architecture in artificial intelligence.pptx
agent architecture in artificial intelligence.pptxagent architecture in artificial intelligence.pptx
agent architecture in artificial intelligence.pptxPriyadharshiniG41
 
trust,bargain,negotiate in artificail intelligence
trust,bargain,negotiate in artificail intelligencetrust,bargain,negotiate in artificail intelligence
trust,bargain,negotiate in artificail intelligencePriyadharshiniG41
 
spirometry classification enhanced using ai
spirometry classification enhanced using aispirometry classification enhanced using ai
spirometry classification enhanced using aiPriyadharshiniG41
 
First order logic or Predicate logic.pptx
First order logic or Predicate logic.pptxFirst order logic or Predicate logic.pptx
First order logic or Predicate logic.pptxPriyadharshiniG41
 
Decision Tree Classification Algorithm.pptx
Decision Tree Classification Algorithm.pptxDecision Tree Classification Algorithm.pptx
Decision Tree Classification Algorithm.pptxPriyadharshiniG41
 
Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxNaïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxPriyadharshiniG41
 

More from PriyadharshiniG41 (20)

understanding-cholera-a-comprehensive-analysis.pdf
understanding-cholera-a-comprehensive-analysis.pdfunderstanding-cholera-a-comprehensive-analysis.pdf
understanding-cholera-a-comprehensive-analysis.pdf
 
combatting-malaria-strategies-for-prevention-and-treatment.pdf
combatting-malaria-strategies-for-prevention-and-treatment.pdfcombatting-malaria-strategies-for-prevention-and-treatment.pdf
combatting-malaria-strategies-for-prevention-and-treatment.pdf
 
ant colony optimization working and explanation
ant colony optimization working and explanationant colony optimization working and explanation
ant colony optimization working and explanation
 
RandomForests in artificial intelligence
RandomForests in artificial intelligenceRandomForests in artificial intelligence
RandomForests in artificial intelligence
 
knowledge representation in artificial intelligence
knowledge representation in artificial intelligenceknowledge representation in artificial intelligence
knowledge representation in artificial intelligence
 
information retrieval in artificial intelligence
information retrieval in artificial intelligenceinformation retrieval in artificial intelligence
information retrieval in artificial intelligence
 
Inference rules in artificial intelligence
Inference rules in artificial intelligenceInference rules in artificial intelligence
Inference rules in artificial intelligence
 
Unit I-Final MArketing analytics unit 1 ppt
Unit I-Final MArketing analytics unit 1 pptUnit I-Final MArketing analytics unit 1 ppt
Unit I-Final MArketing analytics unit 1 ppt
 
agent architecture in artificial intelligence.pptx
agent architecture in artificial intelligence.pptxagent architecture in artificial intelligence.pptx
agent architecture in artificial intelligence.pptx
 
trust,bargain,negotiate in artificail intelligence
trust,bargain,negotiate in artificail intelligencetrust,bargain,negotiate in artificail intelligence
trust,bargain,negotiate in artificail intelligence
 
spirometry classification enhanced using ai
spirometry classification enhanced using aispirometry classification enhanced using ai
spirometry classification enhanced using ai
 
dds.pptx
dds.pptxdds.pptx
dds.pptx
 
actuators.pptx
actuators.pptxactuators.pptx
actuators.pptx
 
First order logic or Predicate logic.pptx
First order logic or Predicate logic.pptxFirst order logic or Predicate logic.pptx
First order logic or Predicate logic.pptx
 
14.08.2020 LKG.pdf
14.08.2020 LKG.pdf14.08.2020 LKG.pdf
14.08.2020 LKG.pdf
 
Decision Tree Classification Algorithm.pptx
Decision Tree Classification Algorithm.pptxDecision Tree Classification Algorithm.pptx
Decision Tree Classification Algorithm.pptx
 
problemsolving with AI.pptx
problemsolving with AI.pptxproblemsolving with AI.pptx
problemsolving with AI.pptx
 
Naïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptxNaïve Bayes Classifier Algorithm.pptx
Naïve Bayes Classifier Algorithm.pptx
 
problem characterstics.pptx
problem characterstics.pptxproblem characterstics.pptx
problem characterstics.pptx
 
ppt.pptx
ppt.pptxppt.pptx
ppt.pptx
 

Recently uploaded

How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAbdelrhman abooda
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 

Recently uploaded (20)

E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 

Minmax and alpha beta pruning.pptx

  • 1. Types of algorithms in Adversarial search • Adversarial search is a game-playing technique where the agents are surrounded by a competitive environment. • 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. • There are following types of adversarial search: – Min-max Algorithm – Alpha-beta Pruning. 10/30/2023 1 Department of CSE (AI/ML)
  • 2. Min-Max Algorithm • In artificial intelligence, minimax is a decision- making strategy under game theory, which is used to minimize the losing chances in a game and to maximize the winning chances. • This strategy is also known as ‘Min-max,’ ’MM,’ or ‘Saddle point.’ 10/30/2023 2 Department of CSE (AI/ML)
  • 3. Min-Max Algorithm • Mini-max algorithm is a recursive or backtracking algorithm which is used in decision-making and game theory. It provides an optimal move for the player assuming that opponent is also playing optimally. • Mini-Max algorithm uses recursion to search through the game-tree. • Example : Chess, Checkers, tic-tac-toe • In this algorithm two players play the game; one is called MAX and other is called MIN. 10/30/2023 3 Department of CSE (AI/ML)
  • 4. Mini-Max Algorithm • Both the players fight it as the opponent player gets the minimum benefit while they get the maximum benefit. • MIN: Decrease the chances of MAX to win the game. • MAX: Increases his chances of winning the game. • The minimax algorithm performs a depth-first search algorithm for the exploration of the complete game tree. • The minimax algorithm proceeds all the way down to the terminal node of the tree, then backtrack the tree as the recursion. 10/30/2023 4 Department of CSE (AI/ML)
  • 5. Working of Min-Max Algorithm • MINIMAX algorithm is a backtracking algorithm where it backtracks to pick the best move out of several choices. • MINIMAX strategy follows the DFS (Depth-first search) concept. • Here, we have two players MIN and MAX, and the game is played alternatively between them, i.e., when MAX made a move, then the next turn is of MIN. • It means the move made by MAX is fixed and, he cannot change it. • The same concept is followed in DFS strategy, i.e., we follow the same path and cannot change in the middle. • That’s why in MINIMAX algorithm, instead of BFS, we follow DFS. 10/30/2023 5 Department of CSE (AI/ML)
  • 6. Working of Min-Max Algorithm • Keep on generating the game tree/ search tree till a limit d. • Compute the move using a heuristic function. • Propagate the values from the leaf node till the current position following the minimax strategy. • Make the best move from the choices. 10/30/2023 6 Department of CSE (AI/ML)
  • 7. Pseudocode for Minimax Algorithm 10/30/2023 Department of CSE (AI/ML) 7
  • 8. Step 1 • In the first step, the algorithm generates the entire game-tree and apply the utility function to get the utility values for the terminal states. • In the below tree diagram, let's take A is the initial state of the tree. • Suppose maximizer takes first turn which has worst-case initial value =- infinity, and minimizer will take next turn which has worst- case initial value = +infinity. 10/30/2023 Department of CSE (AI/ML) 8
  • 9. 10/30/2023 Department of CSE (AI/ML) 9
  • 10. Step 2 • Now, first we find the utilities value for the Maximizer, its initial value is -∞, so we will compare each value in terminal state with initial value of Maximizer and determines the higher nodes values. It will find the maximum among the all. • For node D max(-1,- -∞) => max(-1,4)= 4 • For Node E max(2, -∞) => max(2, 6)= 6 • For Node F max(-3, -∞) => max(-3,-5) = -3 • For node G max(0, -∞) = max(0, 7) = 7 10/30/2023 Department of CSE (AI/ML) 10
  • 11. 10/30/2023 Department of CSE (AI/ML) 11
  • 12. Step 3 • In the next step, it's a turn for minimizer, so it will compare all nodes value with +∞ and will find the 3rd layer node values. • For node B= min(4,6) = 4 • For node C= min (-3, 7) = -3 10/30/2023 Department of CSE (AI/ML) 12
  • 13. 10/30/2023 Department of CSE (AI/ML) 13
  • 14. Step 4 • Now it's a turn for Maximizer, and it will again choose the maximum of all nodes value and find the maximum value for the root node. • In this game tree, there are only 4 layers, hence we reach immediately to the root node, but in real games, there will be more than 4 layers. • For node A max(4, -3)= 4 10/30/2023 Department of CSE (AI/ML) 14
  • 15. 10/30/2023 Department of CSE (AI/ML) 15
  • 16. Example 2 10/30/2023 Department of CSE (AI/ML) 16
  • 18. Limitation of the minimax Algorithm • The main drawback of the minimax algorithm is that it gets really slow for complex games such as Chess, go, etc. • This type of games has a huge branching factor, and the player has lots of choices to decide. • This limitation of the minimax algorithm can be improved from alpha-beta pruning. 10/30/2023 Department of CSE (AI/ML) 18
  • 19. Alpha-Beta Pruning Exploiting the Fact of an Adversary • If a position is provably bad: – It is NO USE expending search time to find out exactly how bad • If the adversary can force a bad position: – It is NO USE expending search time to find out the good positions that the adversary won’t let you achieve anyway • Bad = not better than we already know we can achieve elsewhere. • Contrast normal search: – ANY node might be a winner. – ALL nodes must be considered. – (A* avoids this through knowledge, i.e., heuristics)
  • 20. Another Alpha-Beta Example (−∞, +∞) (−∞,+∞) Range of possible values Do DF-search until first leaf
  • 29. General alpha-beta pruning • Consider a node n in the tree --- • If player has a better choice at: – Parent node of n – Or any choice point further up • Then n will never be reached in play. • Hence, when that much is known about n, it can be pruned.
  • 30. Alpha-beta Algorithm • Depth first search – only considers nodes along a single path from root at any time a = highest-value choice found at any choice point of path for MAX (initially, a = −infinity) b = lowest-value choice found at any choice point of path for MIN (initially, b = +infinity) • Pass current values of a and b down to child nodes during search. • Update values of a and b during search: – MAX updates a at MAX nodes – MIN updates b at MIN nodes • Prune remaining branches at a node when a ≥ b
  • 31. When to Prune • Prune whenever a ≥ b. – Prune below a Max node whose alpha value becomes greater than or equal to the beta value of its ancestors. • Max nodes update alpha based on children’s returned values. – Prune below a Min node whose beta value becomes less than or equal to the alpha value of its ancestors. • Min nodes update beta based on children’s returned values.
  • 32. Alpha-Beta Example Revisited a, b, initial values Do DF-search until first leaf a=− b =+ a=− b =+ a, b, passed to kids
  • 33. Alpha-Beta Example (continued) MIN updates b, based on kids a=− b =+ a=− b =3
  • 34. Alpha-Beta Example (continued) a=− b =3 MIN updates b, based on kids. No change. a=− b =+
  • 35. Alpha-Beta Example (continued) MAX updates a, based on kids. a=3 b =+ 3 is returned as node value.
  • 36. Alpha-Beta Example (continued) a=3 b =+ a=3 b =+ a, b, passed to kids
  • 37. Alpha-Beta Example (continued) a=3 b =+ a=3 b =2 MIN updates b, based on kids.
  • 38. Alpha-Beta Example (continued) a=3 b =2 a ≥ b, so prune. a=3 b =+
  • 39. Alpha-Beta Example (continued) 2 is returned as node value. MAX updates a, based on kids. No change. a=3 b =+
  • 40. Alpha-Beta Example (continued) , a=3 b =+ a=3 b =+ a, b, passed to kids
  • 41. Alpha-Beta Example (continued) , a=3 b =14 a=3 b =+ MIN updates b, based on kids.
  • 42. Alpha-Beta Example (continued) , a=3 b =5 a=3 b =+ MIN updates b, based on kids.
  • 43. Alpha-Beta Example (continued) a=3 b =+ 2 is returned as node value. 2
  • 44. Alpha-Beta Example (continued) Max calculates the same node value, and makes the same move! 2
  • 45. Effectiveness of Alpha-Beta Search • Worst-Case – branches are ordered so that no pruning takes place. In this case alpha-beta gives no improvement over exhaustive search • Best-Case – each player’s best move is the left-most child (i.e., evaluated first) – in practice, performance is closer to best rather than worst-case – E.g., sort moves by the remembered move values found last time. – E.g., expand captures first, then threats, then forward moves, etc. – E.g., run Iterative Deepening search, sort by value last iteration. • In practice often get O(b(d/2)) rather than O(bd) – this is the same as having a branching factor of sqrt(b), • (sqrt(b))d = b(d/2),i.e., we effectively go from b to square root of b – e.g., in chess go from b ~ 35 to b ~ 6 • this permits much deeper search in the same amount of time
  • 46. Final Comments about Alpha-Beta Pruning • Pruning does not affect final results • Entire subtrees can be pruned. • Good move ordering improves effectiveness of pruning • Repeated states are again possible. – Store them in memory = transposition table
  • 47. Example 3 4 1 2 7 8 5 6 -which nodes can be pruned?
  • 48. Answer to Example 3 4 1 2 7 8 5 6 -which nodes can be pruned? Answer: NONE! Because the most favorable nodes for both are explored last (i.e., in the diagram, are on the right-hand side). Max Min Max
  • 49. Second Example (the exact mirror image of the first example) 6 5 8 7 2 1 3 4 -which nodes can be pruned?
  • 50. Answer to Second Example (the exact mirror image of the first example) 6 5 8 7 2 1 3 4 -which nodes can be pruned? Min Max Max Answer: LOTS! Because the most favorable nodes for both are explored first (i.e., in the diagram, are on the left-hand side).