Docsity

Understanding the Minimax Rule and Alpha-Beta Pruning in Game Playing AI, Slides of Introduction to Computing

Partial preview of the text

Download Understanding the Minimax Rule and Alpha-Beta Pruning in Game Playing AI and more Slides Introduction to Computing in PDF only on Docsity!

Game-playing

Part 2

CS

Introduction to Artificial Intelligence

Games: Outline of Unit

Part II

 The Minimax Rule

 Alpha-Beta Pruning

 Game-playing AI successes

The Minimax Procedure

  1. Start with the current position as a MAX node.
  2. Expand the game tree a fixed number of ply (half-moves).
  3. Apply the evaluation function to the leaf positions.
  4. Calculate back-up up values bottom-up.
  5. Pick the move which was chosen to give the MAX value at the root.

2-ply Minimax Example

MAX
MIN

This is the move 2 Evaluation function selected by minimax value

Minimax Algorithm

function MINIMAX-DECISION(state) returns an action inputs: state, current state in game vMAX-VALUE(state) return theaction in SUCCESSORS(state) with value v

function MIN-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v  ∞ for a,s in SUCCESSORS(state) do v  MIN(v, MAX-VALUE(s) ) return v

function MAX-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v  - ∞ for a,s in SUCCESSORS(state) do v  MAX(v, MIN-VALUE(s) ) return v

Comments on Minimax Search

Depth-first search with fixed number of ply as the limit.

  • O(bm) time complexity – Ooops!
  • O(bm) space complexity  Performance will depend on
  • the quality of the evaluation function (expert knowledge)
  • depth of search (computing power and search algorithm)  Differences from normal state space search
  • Looking for one move only
  • No cost on arcs
  • MAX can’t be sure how MIN will respond to his moves  Minimax rule forms the basis for other game tree search algorithms.

10

MINI MAX

Restrictions:

  • 2 players: MAX (computer) and MIN (opponent)  deterministic, perfect information  Select a depth-bound (say: 2) and evaluation function

MAX

MIN

MAX

  • Construct the tree up till the depth-bound
  • Compute the evaluation function for the leaves
  • Propagate the evaluation function upwards: - taking minima in MIN
  • taking maxima in MAX

Select this move

11

The MINI-MAX algorithm:

Initialise depthbound; Minimax (board, depth) = IF depth = depthbound THEN return static_evaluation(board); ELSE IF maximizing_level(depth) THEN FOR EACH child child of board compute Minimax(child, depth+1); return maximum over all children; ELSE IF minimizing_level(depth) THEN FOR EACH child child of board compute Minimax(child, depth+1); return minimum over all children;

Call: Minimax(current_board, 0)

When to Cut Search

Depth Limit: don't search beyond a given depth.

Iterative Deepening: Stop search after a given time (i.e. time is up when resources run out). Assume: (1) 1000 positions/second (2) Branching Factor 35 (3) 150 seconds/move (tournament play)

N = Bd

Max effective ply look ahead = 3-

Game Playing: Adversarial Search

Problem of minimax search

  • Number of games states is exponential to the number of moves.
  • Solution: Do not examine every node ==> Alpha-beta pruning

—Alpha = value of best choice found so far at any choice point along the MAX path. —Beta = value of best choice found so far at any choice point along the MIN path.

Alpha-Beta Pruning

A way to improve the performance of the Minimax Procedure

 Basic idea: “If you have an idea which is surely

bad, don’t take the time to see how truly awful it

is” ~ Pat Winston

2 7 1

=

>=

<=

?

  • We don’t need to compute the value at this node.
  • No matter what it is it can’t effect the value of the root node.

17

Alpha-Beta Cut-off

 Generally applied optimization on Mini-max.

 Instead of:

 first creating the entire tree (up to depth-level)  then doing all propagation

 Interleave the generation of the tree and the propagation of values.

 Point:

 some of the obtained values in the tree will provide information that other (non-generated) parts are redundant and do not need to be generated.

Alpha-Beta Pruning

Traverse the search tree in depth-first orderFor each MAX node n, α(n)=maximum child value found so far

  • Starts with – 
  • Increases if a child returns a value greater than the current α(n)
  • Lower-bound on the final value  For each MIN node n, β(n)=minimum child value found so far
  • Starts with +
  • Decreases if a child returns a value less than the current β(n)
  • Upper-bound on the final value  MAX cutoff rule: At a MAX node n, cut off search if α(n)>=β(n)MIN cutoff rule: At a MIN node n, cut off search if β(n)<=α(n)Carry α and β values down in search

Game Playing: Adversarial Search

Alpha-beta pruning Basic idea:

If you have an idea that is surely bad, don't take the

time to see how truly awful it is.” -- Pat Winston

2 7 1

=

>=

<=

?

  • We don’t need to compute the value at this node.
  • No matter what it is, it can’t effect the value of the root node.

Some branches will never be played by rational players since they include sub-optimal decisions (for either player).