Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

Embed Size (px)

Citation preview

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    1/25

    CHI N L CẾ ƯỢ

    TÌM KI M NÂNG CAOẾ

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    2/25

    MINI-MAX TERMINOLOGY  Utility function: the function applied to leaf

    nodes  Backed-up value

    of a max-position: the value of its largestsuccessor

    of a min-position: the value of its smallestsuccessor

     

    Minimax procedure: search down severallevels; at the bottom level apply the utilityfunction, back-up values all the way up to theroot node, and that node selects the move

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    3/25

    MINIMAX  !erfect play for deterministic games  "dea: choose move to position with highest

    minimax value # best achievable payoff

    against best play  $g, %-ply game:

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    4/25

    MINIMAX STRATEGY  &hy do we take the min value every other

    level of the tree'

      (hese nodes represent the opponent)s choiceof move

      (he computer assumes that the human will

    choose that move that is of least value to thecomputer

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    5/25

    MINIMAX ALGORITHM

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    6/25

    MINIMAX VỚI ĐỘ SÂU GIỚI HẠN 

    Minimax nh *+ xt bu c ph i c to.n b kh/ngư ộ ả ộgian tr ng th0i *+ * c tri n khai * c th g0nạ ượ ể ể ểtr cho c0c n1t l0 v. t2nh ng c l iị ượ ạ  3h/ng khảthi v i c0c b.i to0n l n v4 kh/ng gian tr ng th0i l.ớ ớ ạ

    5u0 l nớ   6i i h n kh/ng gian tr ng th0i l i theo m t *ớ ạ ạ ạ ộ ộs7u n.o * v. gi i h n c0c node con theo m t 5uiớ ạ ột c n.o *ắ

     

    87y l. chi n l c th/ng th ng c a c0c ng iế ượ ườ ủ ườ  ch i c : kh n9ng t2nh tr c bao nhiu n cơ ờ ả ướ ướ  

    6/5/15 6

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    7/25

    MINIMAX VỚI ĐỘ SÂU GIỚI HẠN 

    3hi * ta ch tri n khai c0c n1t con * n * s7uỉ ể ế ộgi i h nớ ạ  80nh gi0 cho c0c n1t n.y nh l. n1t l0 b ng m tư ằ ộ

    h.m l ng gi0 euristicượ   0p d ng chi n l c minimax cho vi c *0nh gi0ụ ế ượ ệ

    c0c n1t c p trnấ  3 thu t n.y g i l. nh4n tr c 3 b c v i 3 la ỹ ậ ọ ướ ướ ớ 

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    8/25

    TIC TAC TOE  =et p be a position in the game  >efine the utility function f?p@ by

    f?p@ #

    largest positive number if p is a win forcomputersmallest negative number if p is a win for

    opponentA> C A>D

      where A> is number of rows, columns anddiagonals in which computer could still win

      and A>D is number of rows, columns anddiagonals in which opponent could still win

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    9/25

    SAMPLE EVALUATIONS  E # omputer; D # Dpponent

      OX

    X O

    rowscolsdiags

    O OX

    X X

    X O

    rowscolsdiags

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    10/25

    MINIMAX IS DONE DEPTH-FIRST

    max

    min

    max

    leaf 

    2 5 1

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    11/25

    PROPERTIES OF MINIMAX  omplete' Fes ?if tree is finite@  Dptimal' Fes ?against an optimal opponent@  (ime complexity' D?bm@

      Gpace complexity' D?bm@ ?depth-firstexploration@

      Hor chess, bIJK, mIL for NreasonableNgames exact solution completely infeasible

    Need to speed it up.

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    12/25

    ALPHA-BETA PROCEDURE  (he alpha-beta procedure can speed up a

    depth-first minimax search  Olpha: a lower bound on the value that a

    max node may ultimately be assignedv P α

      Beta: an upper bound on the value that aminimiQing node may ultimately be assigned

    v R β

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    13/25

    Α-Β PRUNING EXAMPLE

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    14/25

    Α-Β PRUNING EXAMPLE

    alpha cutoff 

    α = 3

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    15/25

    Α-Β PRUNING EXAMPLE

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    16/25

    Α-Β PRUNING EXAMPLE

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    17/25

    Α-Β PRUNING EXAMPLE

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    18/25

    ALPHA CUTOFF≥3

    3

    8 10

    α  3

    !"at "appens "ere# $s t"ere an alp"a cuto%#

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    19/25

    BETA CUTOFF

    &'

    '

    β  '

    ≥8

    8   β cuto% 

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    20/25

    ALPHA-BETA PRUNING

    5 2 10 11 1 2 2 8 ( 5 12 ' 3 25

    max

    min

    max

    e)al

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    21/25

    PROPERTIES OF Α-Β  !runing does not affect final result (his

    means that it gets the exact same result asdoes full minimax

     

    6ood move ordering improves effectivenessof pruning  &ith Nperfect ordering,N time complexity #

    D?bmS%@ doubles depth of search

      O simple example of the value of reasoningabout which computations are relevant ?aform of metareasoning@

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    22/25

    THE Α-Β ALGORITHM

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    23/25

    THE Α-Β ALGORITHM

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    24/25

    WHEN DO WE GET ALPHA

    CUTOFFS?

    ...100

    * 100 * 100

  • 8/21/2019 Chuong 2 - B2 - Cac Chien Luoc Tim Kiem Khac

    25/25

    ASSIGNMENT

    • Using Minimax Olgorithm to solve the (ic-tac-toe