• Keine Ergebnisse gefunden

Foundations of Artificial Intelligence 42. Board Games: Alpha-Beta Search Malte Helmert

N/A
N/A
Protected

Academic year: 2022

Aktie "Foundations of Artificial Intelligence 42. Board Games: Alpha-Beta Search Malte Helmert"

Copied!
30
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)Foundations of Artificial Intelligence 42. Board Games: Alpha-Beta Search. Malte Helmert University of Basel. May 17, 2021.

(2) Alpha-Beta Search. Move Ordering. Board Games: Overview. chapter overview: 40. Introduction and State of the Art 41. Minimax Search and Evaluation Functions 42. Alpha-Beta Search 43. Monte-Carlo Tree Search: Introduction 44. Monte-Carlo Tree Search: Advanced Topics 45. AlphaGo and Outlook. Summary.

(3) Alpha-Beta Search. Move Ordering. Alpha-Beta Search. Summary.

(4) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search 3. MAX A1. 3. A3. 3. MIN A11. A2. 2. A12 A13. 12. 8. A21 A22. 2. 4. 2. A23. 6. Can we save search effort? We do not need to consider all the nodes!. A31 A32. 14. 5. A33. 2.

(5) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search 3. MAX A1. 3. A3. 3. MIN A11. A2. 2. A12 A13. 12. 8. A21 A22. 2. 2. A23. 4. 6. A31 A32. 14. A33. 5. 2. Can we save search effort? We do not need to consider all the nodes! 3. MAX A1. 3. A12 A13. 12. A3. ≤2. 3. MIN A11. A2. 8. A21 A22. 2. A23. 2 A31 A32. 14. 5. A33. 2.

(6) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Generally. Player. Opponent. m. .. .. .. Player Opponent. n. If m > n, then node with utility n will never be reached when playing perfectly!.

(7) Alpha-Beta Search. Move Ordering. Alpha-Beta Search: Idea idea: Use two values α and β during minimax depth-first search, such that the following holds for every recursive call: If the utility value in the current subtree is ≤ α, then the subtree is not interesting because MAX will never enter it when playing perfectly. If the utility value in the current subtree is ≥ β, then the subtree is not interesting because MIN will never enter it when playing perfectly. If α ≥ β in the subtree, then the subtree is not interesting and does not have to be searched further (α-β pruning). Starting with α = −∞ and β = +∞, alpha-beta search produces the identical result as minimax, with lower seach effort.. Summary.

(8) Alpha-Beta Search. Move Ordering. Alpha-Beta Search: Idea idea: Use two values α and β during minimax depth-first search, such that the following holds for every recursive call: If the utility value in the current subtree is ≤ α, then the subtree is not interesting because MAX will never enter it when playing perfectly. If the utility value in the current subtree is ≥ β, then the subtree is not interesting because MIN will never enter it when playing perfectly. If α ≥ β in the subtree, then the subtree is not interesting and does not have to be searched further (α-β pruning). Starting with α = −∞ and β = +∞, alpha-beta search produces the identical result as minimax, with lower seach effort.. Summary.

(9) Alpha-Beta Search. Move Ordering. Alpha-Beta Search: Idea idea: Use two values α and β during minimax depth-first search, such that the following holds for every recursive call: If the utility value in the current subtree is ≤ α, then the subtree is not interesting because MAX will never enter it when playing perfectly. If the utility value in the current subtree is ≥ β, then the subtree is not interesting because MIN will never enter it when playing perfectly. If α ≥ β in the subtree, then the subtree is not interesting and does not have to be searched further (α-β pruning). Starting with α = −∞ and β = +∞, alpha-beta search produces the identical result as minimax, with lower seach effort.. Summary.

(10) Alpha-Beta Search. Move Ordering. Alpha-Beta Search: Idea idea: Use two values α and β during minimax depth-first search, such that the following holds for every recursive call: If the utility value in the current subtree is ≤ α, then the subtree is not interesting because MAX will never enter it when playing perfectly. If the utility value in the current subtree is ≥ β, then the subtree is not interesting because MIN will never enter it when playing perfectly. If α ≥ β in the subtree, then the subtree is not interesting and does not have to be searched further (α-β pruning). Starting with α = −∞ and β = +∞, alpha-beta search produces the identical result as minimax, with lower seach effort.. Summary.

(11) Alpha-Beta Search. Move Ordering. Alpha-Beta Search: Pseudo Code. algorithm skeleton the same as minimax function signature extended by two variables α and β function alpha-beta-main(p) hv , movei := alpha-beta(p, −∞, +∞) return move. Summary.

(12) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Pseudo-Code function alpha-beta(p, α, β) if p is terminal position: return hu(p), nonei initialize v and best move for each hmove, p 0 i ∈ succ(p): hv 0 , best move0 i := alpha-beta(p 0 , α, β) update v and best move if player(p) = MAX: if v ≥ β: return hv , nonei α := max{α, v } if player(p) = MIN: if v ≤ α: return hv , nonei β := min{β, v } return hv , best movei. [as in minimax]. [as in minimax].

(13) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. −∞, [−∞, ∞]. MAX A1. A2. A3. MIN A11. 3. A12 A13. 12. 8. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(14) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. −∞, [−∞, ∞]. MAX A1. 3. A3. ∞, [−∞, ∞]. MIN A11. A2. A12 A13. 12. 8. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(15) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. −∞, [−∞, ∞]. MAX A1. 3. A3. 3, [−∞, 3]. MIN A11. A2. A12 A13. 12. 8. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(16) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. −∞, [−∞, ∞]. MAX A1. 3. A3. 3, [−∞, 3]. MIN A11. A2. A12 A13. 12. 8. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(17) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. −∞, [−∞, ∞]. MAX A1. 3. A3. 3, [−∞, 3]. MIN A11. A2. A12 A13. 12. 8. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(18) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. 3, [3, ∞]. MAX A1. 3. A3. 3, [−∞, 3]. MIN A11. A2. A12 A13. 12. 8. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(19) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. 3, [3, ∞]. MAX A1. 3. A12 A13. 12. 8. A3. ∞, [3, ∞]. 3, [−∞, 3]. MIN A11. A2. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(20) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. 3, [3, ∞]. MAX A1. 3. A12 A13. 12. 8. A3. 2, [3, ∞]. 3, [−∞, 3]. MIN A11. A2. A21 A22. 2. A23. A31 A32. 14. 5. A33. 2.

(21) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. 3, [3, ∞]. MAX A1. 3. A12 A13. 12. 8. A3. 2, [3, ∞]. 3, [−∞, 3]. MIN A11. A2. A21 A22. 2. A23. ∞, [3, ∞] A31 A32. 14. 5. A33. 2.

(22) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. 3, [3, ∞]. MAX A1. 3. A12 A13. 12. 8. A3. 2, [3, ∞]. 3, [−∞, 3]. MIN A11. A2. A21 A22. 2. A23. 14, [3, 14] A31 A32. 14. 5. A33. 2.

(23) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. 3, [3, ∞]. MAX A1. 3. A12 A13. 12. 8. A3. 2, [3, ∞]. 3, [−∞, 3]. MIN A11. A2. A21 A22. 2. A23. 5, [3, 5] A31 A32. 14. 5. A33. 2.

(24) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example. 3, [3, ∞]. MAX A1. 3. A12 A13. 12. 8. A3. 2, [3, ∞]. 3, [−∞, 3]. MIN A11. A2. A21 A22. 2. A23. 2, [3, 5] A31 A32. 14. 5. A33. 2.

(25) Alpha-Beta Search. Move Ordering. Move Ordering. Summary.

(26) Alpha-Beta Search. Move Ordering. Summary. Alpha-Beta Search: Example 3, [3, ∞]. MAX A1. 3. A12 A13. 12. 8. A3. 2, [3, ∞]. 3, [−∞, 3]. MIN A11. A2. A21 A22. 2. A23. 2, [3, 5] A31 A32. 14. 5. A33. 2. If the last successor had been first, the rest of the subtree would have been pruned..

(27) Alpha-Beta Search. Move Ordering. Summary. Move Ordering. idea: first consider the successors that are likely to be best Domain-specific ordering function e.g. chess: captures < threats < forward moves < backward moves Dynamic move-ordering first try moves that have been good in the past e.g., in iterative deepening search: best moves from previous iteration.

(28) Alpha-Beta Search. Move Ordering. How Much Do We Gain with Alpha-Beta Search? assumption: uniform game tree, depth d, branching factor b ≥ 2; assumption: MAX and MIN positions alternating perfect move ordering best move at every position is considered first (this cannot be done in practice – Why?) maximizing move for MAX, minimizing move for MIN effort reduced from O(b d ) (minimax) to O(b d/2 ) doubles the search depth that can be achieved in same time. random move ordering effort still reduced to O(b 3d/4 ) (for moderate b). In practice, it is often possible to get close to the optimum.. Summary.

(29) Alpha-Beta Search. Move Ordering. Summary. Summary.

(30) Alpha-Beta Search. Move Ordering. Summary. alpha-beta search stores which utility both players can force somewhere else in the game tree exploits this information to avoid unnecessary computations can have significantly lower search effort than minimax best case: search twice as deep in the same time. Summary.

(31)

Referenzen

ÄHNLICHE DOKUMENTE

breadth-first search ( this chapter) uniform cost search ( Chapter 11) depth-first search ( Chapter 12) depth-limited search ( Chapter 12) iterative deepening search ( Chapter

breadth-first search optimal if all action costs equal otherwise no optimality guarantee example:.. remedy: uniform

space complexity O(bm) if m maximal search depth reached low memory complexity main reason why depth-first search interesting despite its disadvantages.. Depth-first

heuristics estimate distance of a state to the goal can be used to focus search on promising states soon: search algorithms that

In IDDFS, we grow the limit from the smallest limit that gives a non-empty search tree (0) by 1 at a time. This usually leads to exponential growth of

in every clause, choose the variables randomly literals positive or negative with equal probability critical parameter: #clauses divided by #variables phase transition at ratio ≈

As in classical search problems, the number of positions of (interesting) board games is huge:. Chess: roughly 10 40

Minimax is the simplest (decent) search algorithm for games Yields optimal strategy ∗ (in the game-theoretic sense, i.e., under the assumption that the opponent plays perfectly), but