Min-Max Trees - PowerPoint PPT Presentation

About This Presentation
Title:

Min-Max Trees

Description:

Two Players Games. One Search Tree for both Players. Even layers Max Player move ... function Max-Value(state,game,alpha,beta) returns. minmax value of state ... – PowerPoint PPT presentation

Number of Views:120
Avg rating:3.0/5.0
Slides: 21
Provided by: csta3
Category:
Tags: games | max | min | trees

less

Transcript and Presenter's Notes

Title: Min-Max Trees


1
Min-Max Trees
Yishay Mansour
  • Based on slides by
  • Rob Powers
  • Ian Gent

2
Two Players Games
  • One Search Tree for both Players
  • Even layers Max Player move
  • Odd Layers Min Player move
  • The state evaluated according to heuristic
    function.

3
MinMax search strategy
  • Generate the whole game tree. (Or up to a
    constant depth)
  • Evaluate Terminal states (Leafs)
  • propagate Min-Max values up from leafs
  • Search for MAX best next move, so that no matter
    what MIN does MAX will be better off
  • For branching factor b and depth search d the
    complexity is O(bd)

4
MinMax first Example
5
1
1
-2
-1
6
MinMax evaluation function
  • function MinMax-Decision(game) returns an
    operator
  • for each op in Operatorgame do
  • Valueop MinMax-Value(Apply(op,game),gam
    e)
  • end
  • return the op with the highest Valueop
  • function MinMax-Value(state,game) returns an
    utility value
  • if Terminal-Testgame(state) then
  • return Utilitygame(state)
  • else if MAXs turn
  • return the highest MinMax-Value of
    Successors(state)
  • else (MINs turn)
  • return the lowest MinMax-Value of
    Successors(state)
  • end

7
Cuting Off Search
  • We want to prune the tree stop exploring
    subtrees with values that will not influence the
    final MinMax root decision
  • In the worst case, no pruning.
  • The complexity is O(bd).
  • In practice, O(bd/2), with branching factor of
    b1/2 instead of b.

8
Alpha Beta First Example
9
Alpha-Beta search cutoff rules
  • Keep track and update two values so far
  • alpha is the value of best choice in the MAX path
  • beta is the value of best choice in the MIN path
  • Rule do not expand node n when beta lt
    alpha
  • for MAX node return beta
  • for MIN node return alpha

10
Alpha and Beta values
  • At a Max node we will store an alpha value
  • the alpha value is lower bound on the exact
    minimax score
  • the true value might be ? ?
  • if we know Min can choose moves with score lt ?
  • then Min will never choose to let Max go to a
    node where the score will be ? or more
  • At a Min node, ? value is similar but opposite
  • Alpha-Beta search uses these values to cut search

11
Alpha Beta in Action
  • Why can we cut off search?
  • Beta 1 lt alpha 2 where the alpha value is at
    an ancestor node
  • At the ancestor node, Max had a choice to get a
    score of at least 2 (maybe more)
  • Max is not going to move right to let Min
    guarantee a score of 1 (maybe less)

12
Alpha and Beta values
  • Max node has ? value
  • the alpha value is lower bound on the exact
    minimax score
  • with best play M ?x can guarantee scoring at
    least ?
  • Min node has ? value
  • the beta value is upper bound on the exact
    minimax score
  • with best play Min can guarantee scoring no more
    than ?
  • At Max node, if an ancestor Min node has ? lt ?
  • Mins best play must never let Max move to this
    node
  • therefore this node is irrelevant
  • if ? ?, Min can do as well without letting Max
    get here
  • so again we need not continue

13
Alpha-Beta Pruning Rule
  • Two key points
  • alpha values can never decrease
  • beta values can never increase
  • Search can be discontinued at a node if
  • It is a Max node and
  • the alpha value is ? the beta of any Min ancestor
  • this is beta cutoff
  • Or it is a Min node and
  • the beta value is ? the alpha of any Max
    ancestor
  • this is alpha cutoff

14
Alpha-Beta prunning
  • function Max-Value(state,game,alpha,beta) returns
  • minmax value of state
  • if Cutoff-Test(state) then return Eval(state)
  • for each s in Successor(state) do
  • alpha Max(alpha,Min-Value(s,
    game,alpha,beta))
  • if beta lt alpha then return beta
  • end return alpha
  • function Min-Value(state,game,alpha,beta) returns
  • minmax value of state
  • if Cutoff-Test(state) then return Eval(state)
  • for each s in Successor(state) do
  • beta Min(beta,Max-Value(s, game,alpha,beta))
  • if beta lt alpha then return alpha
  • end return beta

15

2b Left-gtRight
? -?, ? ?
16
2b Left-gtRight
? 7, ? ?
? -?, ? 4
? 6, ? ?
? 4, ? 6
? -?, ? ?
? -?, ? 4
? 8, ? ?
? 6, ? 8
(Alpha pruning)
? 4, ? ?
? 8, ? 6
? 4, ? 3
? 4, ? 8
? 5, ? 6
(Alpha pruning)
? 8, ? ?
? 4, ? 8
?5, ?8
?5, ?6
17
Beta Pruning
? 4, ? ?
? -?, ? 4
? 4, ? 8
? -?, ? ?
? -?, ? 4
? 8, ? ?
? 4, ? 8
(Alpha pruning)
? 4, ? ?
? 8, ? 6
? 4, ? 3
? 4, ? 8
(Alpha pruning)
9
? 8, ? ?
? 4, ? 8
18
Beta Pruning
? 4, ? ?
? -?, ? 4
? 4, ? 8
? -?, ? ?
? -?, ? 4
? 8, ? ?
? 9, ? 8
(Beta pruning)
(Alpha pruning)
? 4, ? ?
? 8, ? 6
? 4, ? 3
? 4, ? 8
(Alpha pruning)
9
? 8, ? ?
? 4, ? 8
19
2b Right-gtLeft
? -?, ? ?
20
2b Right-gtLeft
? 7, ? ?
? -?, ? ?
? 7, ? 6
? 7, ? 7
(Alpha pruning)
(Alpha pruning)
? 7, ? ?
? 7, ? ?
(Alpha pruning)
? 7, ? 6
? 7, ? ?
? 7, ? -1
(Alpha pruning)
?7, ??
?7, ??
?7, ??
Write a Comment
User Comments (0)
About PowerShow.com