SlideShare a Scribd company logo
1 of 42
Alpha Beta Pruning
in Artificial Intelligence
Savya Sachi
1
Introduction
2
• Alpha-beta pruning is the way through which we can find the optimal
minimax solution while avoiding searching subtrees of moves which won't
be selected. In the search tree for a two-player game, there are two kinds of
nodes, one node represents your move and another node represents
opponent's move.
• Alpha-beta pruning comes from two parameters.
– They describe bounds on the values that appear anywhere along the
path under consideration:
• α = best value(i.e., highest value) choice found so far along the
path for MAX
• β = best value(i.e., lowest value) choice found so far along the
path for MIN
Alpha Beta Pruning
3
• Alpha-beta pruning gets its name from two bounds that are passed along
during the calculation, which restrict the set of possible solutions based on
the portion of the search tree that has already been seen. Specifically,
• Beta is the minimum upper bound of possiblesolutions
• Alpha is the maximum lower bound of possiblesolutions
• Thus, when any new node is being considered as a possible path to the
solution, it can only work if:
where N is the current estimate of the value of the node
Algorithm: Alpha Beta Search
4
Example
5
Initial Assumption for Alpha an d
Beta
6
• At begining, we see only the current state (i.e. the current position of pieces
on the game board). As for upper and lower bounds, all we know is that it's a
number less than infinity and greater than negative infinity. Thus, here's what
the initial situation looks like:
Example
7
• Since the bounds still contain a valid range, we start the problem by
generating the first child state, and passing along the current set of bounds.
At this point our search looks like this:
Example
8
• We are still not down to depth 4, so once
again we will generate the first child node
and pass along our current alpha and beta
values:
Example
9
And once more time
Example
10
• When we get to the first node at depth 4, we run our evaluation function on
the state, and get the value 3. Thus we have this:
Example
11
• We pass this node back to the min node above. Since this is a min node, we
now know that the minimax value of this node must be less than or equal to
3. In other words, we change beta to 3.
Example
12
• Next we generate the next child at depth 4, run our evaluation function, and
return a value of 17 to the min node above:
Example
13
• Since this is a min node and 17 is greater than 3, this child is ignored. Now
we've seen all of the children of this min node, so we return the beta value
to the max node above. Since it is a max node, we now know that it's value
will be greater than or equal to 3, so we change alpha to 3:
Example
14
• We generate the next child and pass the bounds along
Example
15
• Since this node is not at the target depth, we generate its first child, run the
evaluation function on that node, and return it's value
Example
16
• Since this is a min node, we now know that the value of this node willbe
less than or equal to 2, so we change beta to 2:
Example
17
• Certainly, we don't know the
actual value of the node.
There could be a 1 or 0 or -
100 somewhere in the other
children of this node. But
even if there was such a
value, searching for it won't
help us find the optimal
solution in the search tree.
The 2 alone is enough to
make this subtree fruitless,
so we can prune any other
children and return it.
• That's all there is to beta
Pruning…….
Example
18
• Back at the parent max
node, our alpha value is
already 3, which is more
restrictive than 2, so we
don't change it. At this
point we've seen all the
children of this max
node, so we can set its
value to the final alpha
value:
Example
19
• Now we move on to the parent min node.
With the 3 for the first child value, we
know that the value of the min node must
be less than or equal to 3, thus we set beta
to 3:
Example
20
• Since we still have a valid
range, we go on to explore the
next child. We generate the max
node...
Example
21
• ... it's first child min node ...
Example
22
• ... and finally the max node at the
target depth. All along this path, we
merely pass the alpha and beta bounds
along.
Example
23
• At this point, we've seen all
of the children of the min
node, and we haven't
changed the beta bound.
Since we haven't exceeded
the bound, we should return
the actual min value for the
node. Notice that this is
different than the case
where we pruned, in which
case you returned the beta
value. The reason for this
will become apparent
shortly.
Example
24
• Now we return the value to the parent max node. Based on this value, we
know that this max node will have a value of 15 or greater, so we set alpha
to 15:
Example
25
• Once again the alpha and beta bounds have crossed, so we can prune the
rest of this node's children and return the value that exceeded the bound
(i.e. 15). Notice that if we had returned the beta value of the child min node
(3) instead of the actual value (15), we wouldn't have been able to prune
here.
Example
26
• Now the parent min node has seen all
of it's children, so it can select the
minimum value of it's children (3) and
return.
Example
27
• Finally we've finished with the first child of the root max node. We now
know our solution will be at least 3, so we set the alpha value to 3 and go
on to the second child.
Example
28
• Passing the alpha and beta values along as we go, we generate the second
child of the root node...
Example
29
• ... and its first child ...
Example
30
Example
31
Example
32
• The min node parent uses this value to set it's beta value to 2:
Example
33
• Once again we are able to prune the other children of this node and return
the value that exceeded the bound. Since this value isn't greater than the
alpha bound of the parent max node, we don't change the bounds.
Example
34
• From here, we generate the next child of the max node:
Example
35
• Then we generate its child, which is at the target depth. We call the
evaluation function and get its value of 3.
Example
36
• The parent min node uses this value to set its upper bound (beta) to3:
Example
37
• In other words, at this point alpha = beta. Should we prune here? We haven't
actuallyexceeded the bounds, but since alpha and beta are equal, we know
we can't really do better in this subtree.
• The answer is yes, we should prune. The reason is that even though we
can't do better, we might be able to do worse. Remember, the task of
minimax is to find the best move to make at the state represented by the top
level max node. As it happens we've finished with this node's children
anyway, so we return the min value 3.
Example
38
Example
39
• The max node above has now seen all of its children, so it returns the
maximum value of those it has seen, which is 3.
Example
40
• This value is returned to its parent min node, which then has a new upper
bound of 3, so it sets beta to 3:
41
• Once again, we are at a point where alpha and beta are tied, so we prune.
• If you were to run minimax on the list version presented at the start of the
example, your minimax would return a value of 3 and 6 terminal nodes
would have been examined.
Conclusion
42
• Pruning will not affect final results.
• Whole subtrees can be pruned, not just leaves.
• Better move ordering improves effectiveness
of pruning.
• With perfect ordering, time complexity is O(bm/2).
– Effective branching factor of sqrt(b)
– Consequence: alpha-beta pruning can look twice as deep
as minimax in the same amount of time.

More Related Content

What's hot

AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemMohammad Imam Hossain
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AIvikas dhakane
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representationSravanthi Emani
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithmMegha Sharma
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityBhavin Darji
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesSamiaAziz4
 
I. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithmI. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithmvikas dhakane
 
CART – Classification & Regression Trees
CART – Classification & Regression TreesCART – Classification & Regression Trees
CART – Classification & Regression TreesHemant Chetwani
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environmentIffat Anjum
 
Introduction to artificial neural network
Introduction to artificial neural networkIntroduction to artificial neural network
Introduction to artificial neural networkDr. C.V. Suresh Babu
 
Implement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratchImplement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratchEshanAgarwal4
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.mohanrathod18
 

What's hot (20)

Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representation
 
Support Vector Machines ( SVM )
Support Vector Machines ( SVM ) Support Vector Machines ( SVM )
Support Vector Machines ( SVM )
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
 
I. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithmI. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithm
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
CART – Classification & Regression Trees
CART – Classification & Regression TreesCART – Classification & Regression Trees
CART – Classification & Regression Trees
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Introduction to artificial neural network
Introduction to artificial neural networkIntroduction to artificial neural network
Introduction to artificial neural network
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Implement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratchImplement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratch
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 

Similar to Alpha beta pruning in ai

AI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptx
AI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptxAI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptx
AI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptxAsst.prof M.Gokilavani
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer scienceRiazul Islam
 
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.ppt
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.pptfdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.ppt
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.pptKartikGupta711
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework HelpC++ Homework Help
 
AI_Session 15 Alpha–Beta Pruning.pptx
AI_Session 15 Alpha–Beta Pruning.pptxAI_Session 15 Alpha–Beta Pruning.pptx
AI_Session 15 Alpha–Beta Pruning.pptxAsst.prof M.Gokilavani
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.pptssuser148ae0
 
Lecture 22 adversarial search
Lecture 22 adversarial searchLecture 22 adversarial search
Lecture 22 adversarial searchHema Kashyap
 
Insider mathematical
Insider   mathematicalInsider   mathematical
Insider mathematicalAditi Saxena
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpExcel Homework Help
 
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
 
Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitationschidabdu
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
3.4 Polynomial Functions and Their Graphs
3.4 Polynomial Functions and Their Graphs3.4 Polynomial Functions and Their Graphs
3.4 Polynomial Functions and Their Graphssmiller5
 
Chapter3 bp
Chapter3   bpChapter3   bp
Chapter3 bpkumar tm
 
Goldbach conjecture.completeproof.patch3
Goldbach conjecture.completeproof.patch3Goldbach conjecture.completeproof.patch3
Goldbach conjecture.completeproof.patch3ChuongHongPhan
 

Similar to Alpha beta pruning in ai (20)

Alpha-Beta Search
Alpha-Beta SearchAlpha-Beta Search
Alpha-Beta Search
 
AI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptx
AI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptxAI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptx
AI3391 Artificial intelligence Session 16 Alpha–Beta Pruning.pptx
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer science
 
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.ppt
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.pptfdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.ppt
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.ppt
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework Help
 
AI_Session 15 Alpha–Beta Pruning.pptx
AI_Session 15 Alpha–Beta Pruning.pptxAI_Session 15 Alpha–Beta Pruning.pptx
AI_Session 15 Alpha–Beta Pruning.pptx
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
 
Lecture 22 adversarial search
Lecture 22 adversarial searchLecture 22 adversarial search
Lecture 22 adversarial search
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
 
Insider mathematical
Insider   mathematicalInsider   mathematical
Insider mathematical
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment Help
 
n7-LP-simplex.ppt
n7-LP-simplex.pptn7-LP-simplex.ppt
n7-LP-simplex.ppt
 
L06
L06L06
L06
 
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
 
Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitations
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
 
3.4 Polynomial Functions and Their Graphs
3.4 Polynomial Functions and Their Graphs3.4 Polynomial Functions and Their Graphs
3.4 Polynomial Functions and Their Graphs
 
Chapter3 bp
Chapter3   bpChapter3   bp
Chapter3 bp
 
Two player games
Two player gamesTwo player games
Two player games
 
Goldbach conjecture.completeproof.patch3
Goldbach conjecture.completeproof.patch3Goldbach conjecture.completeproof.patch3
Goldbach conjecture.completeproof.patch3
 

More from Savyasachi14

Cryptanalysis by savyasachi
Cryptanalysis by savyasachiCryptanalysis by savyasachi
Cryptanalysis by savyasachiSavyasachi14
 
System requirements specification (srs)
System requirements specification (srs)System requirements specification (srs)
System requirements specification (srs)Savyasachi14
 
Object modeling techniques by savyasachi
Object modeling techniques by savyasachiObject modeling techniques by savyasachi
Object modeling techniques by savyasachiSavyasachi14
 
Software testing ppt
Software testing pptSoftware testing ppt
Software testing pptSavyasachi14
 

More from Savyasachi14 (8)

Cryptanalysis by savyasachi
Cryptanalysis by savyasachiCryptanalysis by savyasachi
Cryptanalysis by savyasachi
 
Goals of security
Goals of securityGoals of security
Goals of security
 
Software design
Software designSoftware design
Software design
 
Encryption
EncryptionEncryption
Encryption
 
System requirements specification (srs)
System requirements specification (srs)System requirements specification (srs)
System requirements specification (srs)
 
Object modeling techniques by savyasachi
Object modeling techniques by savyasachiObject modeling techniques by savyasachi
Object modeling techniques by savyasachi
 
Ids
IdsIds
Ids
 
Software testing ppt
Software testing pptSoftware testing ppt
Software testing ppt
 

Recently uploaded

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 

Recently uploaded (20)

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 

Alpha beta pruning in ai

  • 1. Alpha Beta Pruning in Artificial Intelligence Savya Sachi 1
  • 2. Introduction 2 • Alpha-beta pruning is the way through which we can find the optimal minimax solution while avoiding searching subtrees of moves which won't be selected. In the search tree for a two-player game, there are two kinds of nodes, one node represents your move and another node represents opponent's move. • Alpha-beta pruning comes from two parameters. – They describe bounds on the values that appear anywhere along the path under consideration: • α = best value(i.e., highest value) choice found so far along the path for MAX • β = best value(i.e., lowest value) choice found so far along the path for MIN
  • 3. Alpha Beta Pruning 3 • Alpha-beta pruning gets its name from two bounds that are passed along during the calculation, which restrict the set of possible solutions based on the portion of the search tree that has already been seen. Specifically, • Beta is the minimum upper bound of possiblesolutions • Alpha is the maximum lower bound of possiblesolutions • Thus, when any new node is being considered as a possible path to the solution, it can only work if: where N is the current estimate of the value of the node
  • 6. Initial Assumption for Alpha an d Beta 6 • At begining, we see only the current state (i.e. the current position of pieces on the game board). As for upper and lower bounds, all we know is that it's a number less than infinity and greater than negative infinity. Thus, here's what the initial situation looks like:
  • 7. Example 7 • Since the bounds still contain a valid range, we start the problem by generating the first child state, and passing along the current set of bounds. At this point our search looks like this:
  • 8. Example 8 • We are still not down to depth 4, so once again we will generate the first child node and pass along our current alpha and beta values:
  • 10. Example 10 • When we get to the first node at depth 4, we run our evaluation function on the state, and get the value 3. Thus we have this:
  • 11. Example 11 • We pass this node back to the min node above. Since this is a min node, we now know that the minimax value of this node must be less than or equal to 3. In other words, we change beta to 3.
  • 12. Example 12 • Next we generate the next child at depth 4, run our evaluation function, and return a value of 17 to the min node above:
  • 13. Example 13 • Since this is a min node and 17 is greater than 3, this child is ignored. Now we've seen all of the children of this min node, so we return the beta value to the max node above. Since it is a max node, we now know that it's value will be greater than or equal to 3, so we change alpha to 3:
  • 14. Example 14 • We generate the next child and pass the bounds along
  • 15. Example 15 • Since this node is not at the target depth, we generate its first child, run the evaluation function on that node, and return it's value
  • 16. Example 16 • Since this is a min node, we now know that the value of this node willbe less than or equal to 2, so we change beta to 2:
  • 17. Example 17 • Certainly, we don't know the actual value of the node. There could be a 1 or 0 or - 100 somewhere in the other children of this node. But even if there was such a value, searching for it won't help us find the optimal solution in the search tree. The 2 alone is enough to make this subtree fruitless, so we can prune any other children and return it. • That's all there is to beta Pruning…….
  • 18. Example 18 • Back at the parent max node, our alpha value is already 3, which is more restrictive than 2, so we don't change it. At this point we've seen all the children of this max node, so we can set its value to the final alpha value:
  • 19. Example 19 • Now we move on to the parent min node. With the 3 for the first child value, we know that the value of the min node must be less than or equal to 3, thus we set beta to 3:
  • 20. Example 20 • Since we still have a valid range, we go on to explore the next child. We generate the max node...
  • 21. Example 21 • ... it's first child min node ...
  • 22. Example 22 • ... and finally the max node at the target depth. All along this path, we merely pass the alpha and beta bounds along.
  • 23. Example 23 • At this point, we've seen all of the children of the min node, and we haven't changed the beta bound. Since we haven't exceeded the bound, we should return the actual min value for the node. Notice that this is different than the case where we pruned, in which case you returned the beta value. The reason for this will become apparent shortly.
  • 24. Example 24 • Now we return the value to the parent max node. Based on this value, we know that this max node will have a value of 15 or greater, so we set alpha to 15:
  • 25. Example 25 • Once again the alpha and beta bounds have crossed, so we can prune the rest of this node's children and return the value that exceeded the bound (i.e. 15). Notice that if we had returned the beta value of the child min node (3) instead of the actual value (15), we wouldn't have been able to prune here.
  • 26. Example 26 • Now the parent min node has seen all of it's children, so it can select the minimum value of it's children (3) and return.
  • 27. Example 27 • Finally we've finished with the first child of the root max node. We now know our solution will be at least 3, so we set the alpha value to 3 and go on to the second child.
  • 28. Example 28 • Passing the alpha and beta values along as we go, we generate the second child of the root node...
  • 29. Example 29 • ... and its first child ...
  • 32. Example 32 • The min node parent uses this value to set it's beta value to 2:
  • 33. Example 33 • Once again we are able to prune the other children of this node and return the value that exceeded the bound. Since this value isn't greater than the alpha bound of the parent max node, we don't change the bounds.
  • 34. Example 34 • From here, we generate the next child of the max node:
  • 35. Example 35 • Then we generate its child, which is at the target depth. We call the evaluation function and get its value of 3.
  • 36. Example 36 • The parent min node uses this value to set its upper bound (beta) to3:
  • 37. Example 37 • In other words, at this point alpha = beta. Should we prune here? We haven't actuallyexceeded the bounds, but since alpha and beta are equal, we know we can't really do better in this subtree. • The answer is yes, we should prune. The reason is that even though we can't do better, we might be able to do worse. Remember, the task of minimax is to find the best move to make at the state represented by the top level max node. As it happens we've finished with this node's children anyway, so we return the min value 3.
  • 39. Example 39 • The max node above has now seen all of its children, so it returns the maximum value of those it has seen, which is 3.
  • 40. Example 40 • This value is returned to its parent min node, which then has a new upper bound of 3, so it sets beta to 3:
  • 41. 41 • Once again, we are at a point where alpha and beta are tied, so we prune. • If you were to run minimax on the list version presented at the start of the example, your minimax would return a value of 3 and 6 terminal nodes would have been examined.
  • 42. Conclusion 42 • Pruning will not affect final results. • Whole subtrees can be pruned, not just leaves. • Better move ordering improves effectiveness of pruning. • With perfect ordering, time complexity is O(bm/2). – Effective branching factor of sqrt(b) – Consequence: alpha-beta pruning can look twice as deep as minimax in the same amount of time.