Game Search

2-player game as a search problem

元素 描述
Initial state initial board configuration, which player’s move
Successor function returns a list of (move,state) pairs, each indicating a legal move and the resulting state
Terminal test determine when game is over
Utility function a value for the terminal state, e.g. +1 for win, 0 for draw, -1 for loss.

Minimax Algorithm

  • Generate entire game tree, down to leaves.
  • Evaluate each leaf (terminal state) using utility function.
    • Values are backed up through the tree
    • MAX-level: prefer max value (i.e. you)
    • MIN-level: prefer min value (i.e. opponent)
  • At the root, choose the series of moves which leads to the terminal state w/ highest value.
  • Make the perfect decision
  • Could use Depth-First Search, but not Bidirectional Search since it is BFS(level by level會佔用太多資源)

Max先選A1,接著Min選A11

Alpha-beta pruning

Cutoff-test function

  • Depth limit: a preset limit
  • Iterative-deepening: when time is up, return the move selected by the deepest search
  • Error-prone because of limited search