SlideShare a Scribd company logo
1 of 17
ALPHA-BETA
PRUNING
An OptimizationTechnique for mini-maxAlgorithm
Agenda
■ Pruning
■ Introduction to Alpha-Beta Pruning
■ Nodes Representation
■ Rules for Alpha-Beta Pruning
■ Working
■ Pseudocode/Algorithm
■ Advantages over MIN-MAX
■ Heuristic Improvements
■ Application/Use
■ Conclusion
What Is Pruning?
■ Pruning means “to trim”.
■ An algorithm used to reduce the number of nodes to reach the optimal solution.
■ Works by blocking the evaluation of nodes.
■ Example:
– Alpha-Beta Pruning
Alpha-Beta Pruning
■ An optimization technique for mini-max algorithm.
■ Reduces the computation time by a huge factor.
■ Based on Depth First Search (DFS) searching technique.
■ Allows to search much faster and even go into deeper levels in the game tree.
■ Cuts off branches in the game tree which need not be searched.
■ Pruning is based on a base condition.
■ Keeps track of the best move for each side as it moves throughout the tree.
Alpha-Beta Pruning (Cont.)
■ It passes 2 extra parameters in the minimax function, namely alpha and beta.
■ Alpha is the value of the best (i.e., highest value) choice found for MAX, represented
as .
■ Beta is the value of the best (i.e., lowest value) choice found for MIN, represented as
.
■ Initial value of  is -∞ (i.e. = -∞), worst value for MAX player.
■ Initial value of  is +∞ (i.e.  = +∞), worst value for MIN player.
■ Pruning is based on condition ≥ or ≤.
Nodes Representation
These are also called MAX nodes. The goal at a MAX node is to maximize the value of the
subtree rooted at that node. To do this, a MAX node chooses the child with the greatest
value, and that becomes the value of the MAX node.
These are also called MIN nodes. The goal at a MIN node is to minimize the value of the
subtree rooted at that node. To do this, a MIN node chooses the child with the least
(smallest) value, and that becomes the value of the MIN node.
= -∞
= +∞
≥-∞
≤+∞
Which is equivalent to
At the start of the problem, there is only the current state (i.e. the current position of pieces on the
game board). As for upper and lower bounds, it's a number less than infinity and greater than negative
infinity.Thus, here's what the initial situation looks like as above.
Example 1
Rules for Alpha-Beta Pruning
■ For MIN node
– If β ≤ α of MAX ancestor, prune.
■ For MAX node
– If α ≥ β of MIN ancestor, prune.
■ Values of  and  cannot move upward the tree.
■ Values of  and  can move downward the tree.
■ Firstly find values of  and  & then find the value of Node.
■ Traverse the game tree from Left to Right.
Working of Alpha-Beta Pruning
■ Initialize alpha = -infinity and beta = infinity (i.e.
= -∞ and = ∞) as the worst possible cases. The
condition to prune a node is when alpha becomes
greater than or equal to beta (i.e. >=).
■ Start with assigning the initial values of alpha and
beta to root and since alpha is less than beta we
don’t prune it.
■ Carry these values of alpha and beta to the child
node on the left. And now from the utility value of
the terminal state, we will update the values of
alpha and beta.
■ Repeat the steps and wherever the condition
>= is satisfied prune that branch.
Example 2
Psuedocode/Algorithm
alphabeta(root, no. of nodes, -∞, +∞,TRUE)//calling the function
function alphabeta(node, depth, a, b, maximizingPlayer)//returns heuristic values
if depth=0 or node is terminal node return the heuristic value of the node //base case
if maximizingPlayer isTRUE
{
for each child of the node
{
a= max(a, alphabeta(child, depth-1, a, b, FALSE)) //return Beta value from MIN player or heuristic value
if a ≥ b //condition for pruning
break //prune
}
return a
}
Psuedocode/Algorithm (Cont.)
else if maximizingPlayer is FALSE
{
for each child of the node
{
b= min(b, alphabeta(child, depth-1, a, b,TRUE)) //return Alpha value from MAX player or heuristic value
if a ≥ b //condition for pruning
break //prune
}
return b
}
Example 3
Advantages over native Mini-Max
■ The benefit of alpha-beta pruning lies in the fact that branches of the search tree can
be eliminated.
■ The optimization reduces the effective depth to slightly more than half that of simple
minimax.
■ Alpha-Beta pruning can search a tree twice in the same time that mini-max takes to
search only once.
■ With perfect ordering, we attain time complexity O (b d/2)=O ( 𝑏 𝑑).
■ If b=40 (as in chess), and the search depth is 12 plies, the ratio between optimal and
sorting is a factor of nearly 406 or about 4 billion times.
Heuristic Improvements
■ Iterative deepening is usually used in conjunction with alpha-beta so that a reasonably
good move can be returned.
■ It searches at shallower depths give move-ordering hints that can help produce cutoffs
for higher depth searches much earlier than would otherwise be possible.
■ Uses best-first strategy that potentially makes them more time-efficient, but typically
at a heavy cost in space-efficiency.
■ Alpha-beta search can be made even faster by considering only a narrow search
window (generally determined by guesswork based on experience). This is known as
aspiration search.
Uses/Application of Alpha-Beta Pruning
■ It is an adversarial search algorithm used commonly for machine playing of two-player
games (Tic-tac-toe,Chess, Go, etc.).
■ It is used when a faster searching technique is required.
■ Efficiency is to be increased.
■ Time efficiency is to be decreased.
Conclusion
■ Two values are created during the search: alpha-value (associated with MAX nodes)
and beta-value (associate with MIN nodes). Pruning does not affect final results and
Entire subtrees can be pruned, not just leaves. With perfect ordering, we attain time
complexity O (b d/2) = O ( 𝑏 𝑑). 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
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rulesswapnac12
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and boundAbhishek Singh
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligencelordmwesh
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptarunsingh660
 
Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2DigiGurukul
 
Heuristc Search Techniques
Heuristc Search TechniquesHeuristc Search Techniques
Heuristc Search TechniquesJismy .K.Jose
 
Adversarial Search
Adversarial SearchAdversarial Search
Adversarial SearchMegha Sharma
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchDheerendra k
 
I.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AIvikas dhakane
 
2. forward chaining and backward chaining
2. forward chaining and backward chaining2. forward chaining and backward chaining
2. forward chaining and backward chainingmonircse2
 

What's hot (20)

AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rules
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Minimax
MinimaxMinimax
Minimax
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
Alpha beta pruning
Alpha beta pruningAlpha beta pruning
Alpha beta pruning
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
Support Vector Machines ( SVM )
Support Vector Machines ( SVM ) Support Vector Machines ( SVM )
Support Vector Machines ( SVM )
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.ppt
 
Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2
 
Truth management system
Truth  management systemTruth  management system
Truth management system
 
Heuristc Search Techniques
Heuristc Search TechniquesHeuristc Search Techniques
Heuristc Search Techniques
 
Adversarial Search
Adversarial SearchAdversarial Search
Adversarial Search
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
I.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AI
 
2. forward chaining and backward chaining
2. forward chaining and backward chaining2. forward chaining and backward chaining
2. forward chaining and backward chaining
 

Similar to Optimize Mini-Max Algorithm with Alpha-Beta Pruning

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
 
Minmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptxMinmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptxPriyadharshiniG41
 
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
 
12 adversal search
12 adversal search12 adversal search
12 adversal searchTianlu Wang
 
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
 
cs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.pptcs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.pptSamiksha880257
 
GamePlaying.ppt
GamePlaying.pptGamePlaying.ppt
GamePlaying.pptVihaanN2
 
AI-MiniMax Algorithm and Alpha Beta Reduction
AI-MiniMax Algorithm and Alpha Beta ReductionAI-MiniMax Algorithm and Alpha Beta Reduction
AI-MiniMax Algorithm and Alpha Beta ReductionMahfuzul Yamin
 
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCEudayvanand
 
Artificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptxArtificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptxKalpana Mohan
 

Similar to Optimize Mini-Max Algorithm with Alpha-Beta Pruning (20)

Alpha-Beta Search
Alpha-Beta SearchAlpha-Beta Search
Alpha-Beta 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
 
Minmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptxMinmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptx
 
Capgemini 1
Capgemini 1Capgemini 1
Capgemini 1
 
AI Lesson 08
AI Lesson 08AI Lesson 08
AI Lesson 08
 
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
 
12 adversal search
12 adversal search12 adversal search
12 adversal search
 
Parallel searching
Parallel searchingParallel searching
Parallel searching
 
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
 
cs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.pptcs-171-07-Games and Adversarila Search.ppt
cs-171-07-Games and Adversarila Search.ppt
 
Two player games
Two player gamesTwo player games
Two player games
 
GamePlaying.ppt
GamePlaying.pptGamePlaying.ppt
GamePlaying.ppt
 
jfs-masters-1
jfs-masters-1jfs-masters-1
jfs-masters-1
 
AI-MiniMax Algorithm and Alpha Beta Reduction
AI-MiniMax Algorithm and Alpha Beta ReductionAI-MiniMax Algorithm and Alpha Beta Reduction
AI-MiniMax Algorithm and Alpha Beta Reduction
 
AI_unit3.pptx
AI_unit3.pptxAI_unit3.pptx
AI_unit3.pptx
 
Parallel search
Parallel searchParallel search
Parallel search
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
 
Artificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptxArtificial Intelligence Alpha Beta pruning.pptx
Artificial Intelligence Alpha Beta pruning.pptx
 

Recently uploaded

Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxjana861314
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Nistarini College, Purulia (W.B) India
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfSumit Kumar yadav
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...jana861314
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 

Recently uploaded (20)

Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...
 
The Philosophy of Science
The Philosophy of ScienceThe Philosophy of Science
The Philosophy of Science
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdf
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 

Optimize Mini-Max Algorithm with Alpha-Beta Pruning

  • 2. Agenda ■ Pruning ■ Introduction to Alpha-Beta Pruning ■ Nodes Representation ■ Rules for Alpha-Beta Pruning ■ Working ■ Pseudocode/Algorithm ■ Advantages over MIN-MAX ■ Heuristic Improvements ■ Application/Use ■ Conclusion
  • 3. What Is Pruning? ■ Pruning means “to trim”. ■ An algorithm used to reduce the number of nodes to reach the optimal solution. ■ Works by blocking the evaluation of nodes. ■ Example: – Alpha-Beta Pruning
  • 4. Alpha-Beta Pruning ■ An optimization technique for mini-max algorithm. ■ Reduces the computation time by a huge factor. ■ Based on Depth First Search (DFS) searching technique. ■ Allows to search much faster and even go into deeper levels in the game tree. ■ Cuts off branches in the game tree which need not be searched. ■ Pruning is based on a base condition. ■ Keeps track of the best move for each side as it moves throughout the tree.
  • 5. Alpha-Beta Pruning (Cont.) ■ It passes 2 extra parameters in the minimax function, namely alpha and beta. ■ Alpha is the value of the best (i.e., highest value) choice found for MAX, represented as . ■ Beta is the value of the best (i.e., lowest value) choice found for MIN, represented as . ■ Initial value of  is -∞ (i.e. = -∞), worst value for MAX player. ■ Initial value of  is +∞ (i.e.  = +∞), worst value for MIN player. ■ Pruning is based on condition ≥ or ≤.
  • 6. Nodes Representation These are also called MAX nodes. The goal at a MAX node is to maximize the value of the subtree rooted at that node. To do this, a MAX node chooses the child with the greatest value, and that becomes the value of the MAX node. These are also called MIN nodes. The goal at a MIN node is to minimize the value of the subtree rooted at that node. To do this, a MIN node chooses the child with the least (smallest) value, and that becomes the value of the MIN node. = -∞ = +∞ ≥-∞ ≤+∞ Which is equivalent to At the start of the problem, there is only the current state (i.e. the current position of pieces on the game board). As for upper and lower bounds, it's a number less than infinity and greater than negative infinity.Thus, here's what the initial situation looks like as above.
  • 8. Rules for Alpha-Beta Pruning ■ For MIN node – If β ≤ α of MAX ancestor, prune. ■ For MAX node – If α ≥ β of MIN ancestor, prune. ■ Values of  and  cannot move upward the tree. ■ Values of  and  can move downward the tree. ■ Firstly find values of  and  & then find the value of Node. ■ Traverse the game tree from Left to Right.
  • 9. Working of Alpha-Beta Pruning ■ Initialize alpha = -infinity and beta = infinity (i.e. = -∞ and = ∞) as the worst possible cases. The condition to prune a node is when alpha becomes greater than or equal to beta (i.e. >=). ■ Start with assigning the initial values of alpha and beta to root and since alpha is less than beta we don’t prune it. ■ Carry these values of alpha and beta to the child node on the left. And now from the utility value of the terminal state, we will update the values of alpha and beta. ■ Repeat the steps and wherever the condition >= is satisfied prune that branch.
  • 11. Psuedocode/Algorithm alphabeta(root, no. of nodes, -∞, +∞,TRUE)//calling the function function alphabeta(node, depth, a, b, maximizingPlayer)//returns heuristic values if depth=0 or node is terminal node return the heuristic value of the node //base case if maximizingPlayer isTRUE { for each child of the node { a= max(a, alphabeta(child, depth-1, a, b, FALSE)) //return Beta value from MIN player or heuristic value if a ≥ b //condition for pruning break //prune } return a }
  • 12. Psuedocode/Algorithm (Cont.) else if maximizingPlayer is FALSE { for each child of the node { b= min(b, alphabeta(child, depth-1, a, b,TRUE)) //return Alpha value from MAX player or heuristic value if a ≥ b //condition for pruning break //prune } return b }
  • 14. Advantages over native Mini-Max ■ The benefit of alpha-beta pruning lies in the fact that branches of the search tree can be eliminated. ■ The optimization reduces the effective depth to slightly more than half that of simple minimax. ■ Alpha-Beta pruning can search a tree twice in the same time that mini-max takes to search only once. ■ With perfect ordering, we attain time complexity O (b d/2)=O ( 𝑏 𝑑). ■ If b=40 (as in chess), and the search depth is 12 plies, the ratio between optimal and sorting is a factor of nearly 406 or about 4 billion times.
  • 15. Heuristic Improvements ■ Iterative deepening is usually used in conjunction with alpha-beta so that a reasonably good move can be returned. ■ It searches at shallower depths give move-ordering hints that can help produce cutoffs for higher depth searches much earlier than would otherwise be possible. ■ Uses best-first strategy that potentially makes them more time-efficient, but typically at a heavy cost in space-efficiency. ■ Alpha-beta search can be made even faster by considering only a narrow search window (generally determined by guesswork based on experience). This is known as aspiration search.
  • 16. Uses/Application of Alpha-Beta Pruning ■ It is an adversarial search algorithm used commonly for machine playing of two-player games (Tic-tac-toe,Chess, Go, etc.). ■ It is used when a faster searching technique is required. ■ Efficiency is to be increased. ■ Time efficiency is to be decreased.
  • 17. Conclusion ■ Two values are created during the search: alpha-value (associated with MAX nodes) and beta-value (associate with MIN nodes). Pruning does not affect final results and Entire subtrees can be pruned, not just leaves. With perfect ordering, we attain time complexity O (b d/2) = O ( 𝑏 𝑑). Alpha-beta pruning can look twice as deep as minimax in the same amount of time.