SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Alpha Beta Pruning
Lecture-23
Hema Kashyap
1
Introduction
• Alpha-beta pruning is a way of finding 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, nodes
representing your moves and nodes representing your opponent's moves.
• Alpha-beta pruning gets its name from two parameters.
– They describe bounds on the values that appear anywhere along the
path under consideration:
• α = the value of the best (i.e., highest value) choice found so far
along the path for MAX
• β = the value of the best (i.e., lowest value) choice found so far
along the path for MIN
2
Alpha Beta Pruning
• 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 possible solutions
• Alpha is the maximum lower bound of possible solutions
• 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
3
Algorithm: Alpha Beta Search
4
Example
5
Initial Assumption for Alpha an d Beta
• At the start of the problem, you see only the current state (i.e. the current
position of pieces on the game board). As for upper and lower bounds, all you
know is that it's a number less than infinity and greater than negative infinity.
Thus, here's what the initial situation looks like:
6
Example
• 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:
7
Example
• We're still not down to depth 4, so once again
we generate the first child node and pass
along our current alpha and beta values:
8
Example
• And one more time
9
Example
• 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:
10
Example
• 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.
11
Example
• Next we generate the next child at depth 4, run our evaluation function, and
return a value of 17 to the min node above:
12
Example
• 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:
13
Example
• We generate the next child and pass the bounds along
14
Example
• 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
15
Example
• Since this is a min node, we now know that the value of this node will be
less than or equal to 2, so we change beta to 2:
16
Example
• Admittedly, 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!
17
Example
• 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:
18
Example
• 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:
19
Example
• Since we still have a valid
range, we go on to explore the
next child. We generate the max
node...
20
Example
• ... it's first child min node ...
21
Example
• ... and finally the max node at the
target depth. All along this path, we
merely pass the alpha and beta bounds
along.
22
Example
• 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.
23
Example
• 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:
24
Example
• 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.
25
Example
• 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.
26
Example
• 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.
27
Example
• Passing the alpha and beta values along as we go, we generate the second
child of the root node...
28
Example
• ... and its first child ...
29
Example
30
Example
31
Example
• The min node parent uses this value to set it's beta value to 2:
32
Example
• 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.
33
Example
• From here, we generate the next child of the max node:
34
Example
• Then we generate its child, which is at the target depth. We call the
evaluation function and get its value of 3.
35
Example
• The parent min node uses this value to set its upper bound (beta) to 3:
36
Example
• 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.
37
Example
38
Example
• 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.
39
Example
• This value is returned to its parent min node, which then has a new upper
bound of 3, so it sets beta to 3:
40
• Once again, we're at a point where alpha and beta are tied, so we
prune. Note that a real solution doesn't just indicate a number, but what
move led to that number.
• 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
41
Conclusion
• Pruning does not affect final results.
• Entire subtrees can be pruned, not just leaves.
• Good 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.
42

Weitere ähnliche Inhalte

Was ist angesagt?

Adversarial search
Adversarial searchAdversarial search
Adversarial search
Nilu Desai
 
Constraint satisfaction problems (csp)
Constraint satisfaction problems (csp)   Constraint satisfaction problems (csp)
Constraint satisfaction problems (csp)
Archana432045
 

Was ist angesagt? (20)

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
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Adversarial Search
Adversarial SearchAdversarial Search
Adversarial Search
 
5 csp
5 csp5 csp
5 csp
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
 
Alpha beta pruning
Alpha beta pruningAlpha beta pruning
Alpha beta pruning
 
State Space Search in ai
State Space Search in aiState Space Search in ai
State Space Search in ai
 
Heuristc Search Techniques
Heuristc Search TechniquesHeuristc Search Techniques
Heuristc Search Techniques
 
Heuristic search-in-artificial-intelligence
Heuristic search-in-artificial-intelligenceHeuristic search-in-artificial-intelligence
Heuristic search-in-artificial-intelligence
 
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)
 
Problems, Problem spaces and Search
Problems, Problem spaces and SearchProblems, Problem spaces and Search
Problems, Problem spaces and Search
 
State Space Representation and Search
State Space Representation and SearchState Space Representation and Search
State Space Representation and Search
 
Constraint satisfaction problems (csp)
Constraint satisfaction problems (csp)   Constraint satisfaction problems (csp)
Constraint satisfaction problems (csp)
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
 

Andere mochten auch

12 adversal search
12 adversal search12 adversal search
12 adversal search
Tianlu Wang
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
chandsek666
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2
chandsek666
 
Heuristic Search
Heuristic SearchHeuristic Search
Heuristic Search
butest
 

Andere mochten auch (20)

Alpha beta pruning
Alpha beta pruningAlpha beta pruning
Alpha beta pruning
 
Alpha beta prouning
Alpha beta prouningAlpha beta prouning
Alpha beta prouning
 
Alphabeta
AlphabetaAlphabeta
Alphabeta
 
Adversarial search
Adversarial search Adversarial search
Adversarial search
 
Minimax
MinimaxMinimax
Minimax
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
12 adversal search
12 adversal search12 adversal search
12 adversal search
 
Lecture 09 uninformed problem solving
Lecture 09 uninformed problem solvingLecture 09 uninformed problem solving
Lecture 09 uninformed problem solving
 
AI Lesson 08
AI Lesson 08AI Lesson 08
AI Lesson 08
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic Searches
 
Adversarial search with Game Playing
Adversarial search with Game PlayingAdversarial search with Game Playing
Adversarial search with Game Playing
 
Ch2 3-informed (heuristic) search
Ch2 3-informed (heuristic) searchCh2 3-informed (heuristic) search
Ch2 3-informed (heuristic) search
 
Update on-crisp-iana-stewardship-transition
Update on-crisp-iana-stewardship-transitionUpdate on-crisp-iana-stewardship-transition
Update on-crisp-iana-stewardship-transition
 
Game Playing In A I Final
Game  Playing In  A I  FinalGame  Playing In  A I  Final
Game Playing In A I Final
 
Writing a good cv
Writing a good cvWriting a good cv
Writing a good cv
 
Searchadditional2
Searchadditional2Searchadditional2
Searchadditional2
 
Core java tutorial
Core java tutorialCore java tutorial
Core java tutorial
 
The Unified Modelling Lanage (UML)
The Unified Modelling Lanage (UML)The Unified Modelling Lanage (UML)
The Unified Modelling Lanage (UML)
 
Modern Portfolio Theory (Mpt) - AAII Milwaukee
Modern Portfolio Theory (Mpt) - AAII MilwaukeeModern Portfolio Theory (Mpt) - AAII Milwaukee
Modern Portfolio Theory (Mpt) - AAII Milwaukee
 
Heuristic Search
Heuristic SearchHeuristic Search
Heuristic Search
 

Ähnlich wie Lecture 23 alpha beta pruning

Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
22bcs058
 
Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitations
chidabdu
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
ssuser148ae0
 

Ähnlich wie Lecture 23 alpha beta pruning (20)

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
 
Insider mathematical
Insider   mathematicalInsider   mathematical
Insider mathematical
 
Alpha-Beta Search
Alpha-Beta SearchAlpha-Beta Search
Alpha-Beta Search
 
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer science
 
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
 
Backtracking
BacktrackingBacktracking
Backtracking
 
DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment Help
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
 
Chapter - 1 Real_Numbers CLASS 10 MATHS.pdf
Chapter - 1 Real_Numbers CLASS 10 MATHS.pdfChapter - 1 Real_Numbers CLASS 10 MATHS.pdf
Chapter - 1 Real_Numbers CLASS 10 MATHS.pdf
 
n7-LP-simplex.ppt
n7-LP-simplex.pptn7-LP-simplex.ppt
n7-LP-simplex.ppt
 
Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitations
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
 
Binomial theorem
Binomial theoremBinomial theorem
Binomial theorem
 
4.4
4.44.4
4.4
 
Group 1
Group 1Group 1
Group 1
 
Group 1
Group 1Group 1
Group 1
 
Group 1
Group 1Group 1
Group 1
 
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
 

Mehr von Hema Kashyap

Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniques
Hema Kashyap
 

Mehr von Hema Kashyap (20)

Lecture 30 introduction to logic
Lecture 30 introduction to logicLecture 30 introduction to logic
Lecture 30 introduction to logic
 
Lecture 29 genetic algorithm-example
Lecture 29 genetic algorithm-exampleLecture 29 genetic algorithm-example
Lecture 29 genetic algorithm-example
 
Lecture 28 genetic algorithm
Lecture 28 genetic algorithmLecture 28 genetic algorithm
Lecture 28 genetic algorithm
 
Lecture 27 simulated annealing
Lecture 27 simulated annealingLecture 27 simulated annealing
Lecture 27 simulated annealing
 
Lecture 26 local beam search
Lecture 26 local beam searchLecture 26 local beam search
Lecture 26 local beam search
 
Lecture 25 hill climbing
Lecture 25 hill climbingLecture 25 hill climbing
Lecture 25 hill climbing
 
Lecture 24 iterative improvement algorithm
Lecture 24 iterative improvement algorithmLecture 24 iterative improvement algorithm
Lecture 24 iterative improvement algorithm
 
Lecture 22 adversarial search
Lecture 22 adversarial searchLecture 22 adversarial search
Lecture 22 adversarial search
 
Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star search
 
Lecture 20 problem reduction search
Lecture 20 problem reduction searchLecture 20 problem reduction search
Lecture 20 problem reduction search
 
Lecture 19 sma star algorithm
Lecture 19 sma star algorithmLecture 19 sma star algorithm
Lecture 19 sma star algorithm
 
Lecture 18 simplified memory bound a star algorithm
Lecture 18 simplified memory bound a star algorithmLecture 18 simplified memory bound a star algorithm
Lecture 18 simplified memory bound a star algorithm
 
Lecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithmLecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithm
 
Lecture 16 memory bounded search
Lecture 16 memory bounded searchLecture 16 memory bounded search
Lecture 16 memory bounded search
 
Lecture 15 monkey banana problem
Lecture 15 monkey banana problemLecture 15 monkey banana problem
Lecture 15 monkey banana problem
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithm
 
Lecture 13 Criptarithmetic problem
Lecture 13 Criptarithmetic problemLecture 13 Criptarithmetic problem
Lecture 13 Criptarithmetic problem
 
Lecture 11 Informed Search
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed Search
 
Lecture 10 Uninformed Search Techniques conti..
Lecture 10 Uninformed Search Techniques conti..Lecture 10 Uninformed Search Techniques conti..
Lecture 10 Uninformed Search Techniques conti..
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniques
 

Kürzlich hochgeladen

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Kürzlich hochgeladen (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 

Lecture 23 alpha beta pruning

  • 2. Introduction • Alpha-beta pruning is a way of finding 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, nodes representing your moves and nodes representing your opponent's moves. • Alpha-beta pruning gets its name from two parameters. – They describe bounds on the values that appear anywhere along the path under consideration: • α = the value of the best (i.e., highest value) choice found so far along the path for MAX • β = the value of the best (i.e., lowest value) choice found so far along the path for MIN 2
  • 3. Alpha Beta Pruning • 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 possible solutions • Alpha is the maximum lower bound of possible solutions • 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 3
  • 6. Initial Assumption for Alpha an d Beta • At the start of the problem, you see only the current state (i.e. the current position of pieces on the game board). As for upper and lower bounds, all you know is that it's a number less than infinity and greater than negative infinity. Thus, here's what the initial situation looks like: 6
  • 7. Example • 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: 7
  • 8. Example • We're still not down to depth 4, so once again we generate the first child node and pass along our current alpha and beta values: 8
  • 9. Example • And one more time 9
  • 10. Example • 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: 10
  • 11. Example • 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. 11
  • 12. Example • Next we generate the next child at depth 4, run our evaluation function, and return a value of 17 to the min node above: 12
  • 13. Example • 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: 13
  • 14. Example • We generate the next child and pass the bounds along 14
  • 15. Example • 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 15
  • 16. Example • Since this is a min node, we now know that the value of this node will be less than or equal to 2, so we change beta to 2: 16
  • 17. Example • Admittedly, 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! 17
  • 18. Example • 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: 18
  • 19. Example • 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: 19
  • 20. Example • Since we still have a valid range, we go on to explore the next child. We generate the max node... 20
  • 21. Example • ... it's first child min node ... 21
  • 22. Example • ... and finally the max node at the target depth. All along this path, we merely pass the alpha and beta bounds along. 22
  • 23. Example • 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. 23
  • 24. Example • 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: 24
  • 25. Example • 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. 25
  • 26. Example • 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. 26
  • 27. Example • 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. 27
  • 28. Example • Passing the alpha and beta values along as we go, we generate the second child of the root node... 28
  • 29. Example • ... and its first child ... 29
  • 32. Example • The min node parent uses this value to set it's beta value to 2: 32
  • 33. Example • 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. 33
  • 34. Example • From here, we generate the next child of the max node: 34
  • 35. Example • Then we generate its child, which is at the target depth. We call the evaluation function and get its value of 3. 35
  • 36. Example • The parent min node uses this value to set its upper bound (beta) to 3: 36
  • 37. Example • 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. 37
  • 39. Example • 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. 39
  • 40. Example • This value is returned to its parent min node, which then has a new upper bound of 3, so it sets beta to 3: 40
  • 41. • Once again, we're at a point where alpha and beta are tied, so we prune. Note that a real solution doesn't just indicate a number, but what move led to that number. • 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 41
  • 42. Conclusion • Pruning does not affect final results. • Entire subtrees can be pruned, not just leaves. • Good 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. 42