Unformatted text preview:

CMSC 671 Fall 2001Today’s classGame PlayingWhy study gamesTypical caseHow to play a gameEvaluation functionEvaluation function examplesGame treesMinimax procedureMinimax AlgorithmPartial Game Tree for Tic-Tac-ToeMinimax TreeAlpha-beta pruningSlide 15Alpha-beta exampleAlpha-beta algorithmEffectiveness of alpha-betaGames of chanceGame Trees with Chance NodesMeaning of the evaluation functionChinookRatings of human and computer chess championsSlide 24CMSC 671CMSC 671Fall 2001Fall 2001Class #8 – Thursday, September 27Today’s class•Game playing•Game trees–Minimax–Alpha-beta pruning–Adding randomness•Deep Blue (da chess champeen of da woild!)Game PlayingGame PlayingChapter 5Some material adopted from notes by Charles R. Dyer, University of Wisconsin-MadisonWhy study games•Clear criteria for success•Offer an opportunity to study problems involving {hostile, adversarial, competing} agents.•Historical reasons•Fun•Interesting, hard problems which require minimal “initial structure”•Games often define very large search spaces–chess 35^100 nodes in search tree, 10^40 legal statesTypical case•2-person game•Players alternate moves •Zero-sum: one player’s loss is the other’s gain•Perfect information: both players have access to complete information about the state of the game. No information is hidden from either player.•No chance (e.g., using dice) involved •Examples: Tic-Tac-Toe, Checkers, Chess, Go, Nim, Othello•Not: Bridge, Solitaire, Backgammon, ...How to play a game•A way to play such a game is to:–Consider all the legal moves you can make–Compute the new position resulting from each move–Evaluate each resulting position and determine which is best–Make that move–Wait for your opponent to move and repeat•Key problems are:–Representing the “board”–Generating all legal next boards–Evaluating a positionEvaluation function•Evaluation function or static evaluator is used to evaluate the “goodness” of a game position.–Contrast with heuristic search where the evaluation function was a non-negative estimate of the cost from the start node to a goal and passing through the given node•The zero-sum assumption allows us to use a single evaluation function to describe the goodness of a board with respect to both players. –f(n) >> 0: position n good for me and bad for you–f(n) << 0: position n bad for me and good for you–f(n) near 0: position n is a neutral position–f(n) = +infinity: win for me–f(n) = -infinity: win for youEvaluation function examples•Example of an evaluation function for Tic-Tac-Toe: f(n) = [# of 3-lengths open for me] - [# of 3-lengths open for you] where a 3-length is a complete row, column, or diagonal•Alan Turing’s function for chess–f(n) = w(n)/b(n) where w(n) = sum of the point value of white’s pieces and b(n) = sum of black’s•Most evaluation functions are specified as a weighted sum of position features:f(n) = w1*feat1(n) + w2*feat2(n) + ... + wn*featk(n) •Example features for chess are piece count, piece placement, squares controlled, etc. •Deep Blue has about 6000 features in its evaluation functionGame trees•Problem spaces for typical games are represented as trees•Root node represents the current board configuration; player must decide the best single move to make next•Static evaluator function rates a board position. f(board) = real number withf>0 “white” (me), f<0 for black (you)•Arcs represent the possible legal moves for a player •If it is my turn to move, then the root is labeled a "MAX" node; otherwise it is labeled a "MIN" node, indicating my opponent's turn. •Each level of the tree has nodes that are all MAX or all MIN; nodes at level i are of the opposite kind from those at level i+1Minimax procedure•Create start node as a MAX node with current board configuration •Expand nodes down to some depth (a.k.a. ply) of lookahead in the game•Apply the evaluation function at each of the leaf nodes •“Back up” values for each of the non-leaf nodes until a value is computed for the root node–At MIN nodes, the backed-up value is the minimum of the values associated with its children. –At MAX nodes, the backed up value is the maximum of the values associated with its children. •Pick the operator associated with the child node whose backed-up value determined the value at the rootMinimax Algorithm2 7 18MAXMIN2 7 18212 7 182 122 7 182 12This is the moveselected by minimaxStatic evaluator valuePartial Game Tree for Tic-Tac-Toe•f(n) = +1 if the position is a win for X.•f(n) = -1 if the position is a win for O.•f(n) = 0 if the position is a draw.Minimax TreeMAX nodeMIN nodef valuevalue computed by minimaxAlpha-beta pruning•We can improve on the performance of the minimax algorithm through 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=2>=2<=1?•We don’t need to compute the value at this node.•No matter what it is, it can’t affect the value of the root node.MAXMAXMINAlpha-beta pruning•Traverse the search tree in depth-first order •At each MAX node n, alpha(n) = maximum value found so far•At each MIN node n, beta(n) = minimum value found so far–Note: The alpha values start at -infinity and only increase, while beta values start at +infinity and only decrease. •Beta cutoff: Given a MAX node n, cut off the search below n (i.e., don’t generate or examine any more of n’s children) if alpha(n) >= beta(i) for some MIN node ancestor i of n. •Alpha cutoff: stop searching below MIN node n if beta(n) <= alpha(i) for some MAX node ancestor i of n.Alpha-beta example312 8 2 14 5 23MINMAX32 - PRUNE14 52Alpha-beta algorithmfunction MAX-VALUE (state, game, alpha, beta) ;; alpha = best MAX so far; beta = best MINif CUTOFF-TEST (state) then return EVAL (state)for each s in SUCCESSORS (state) do alpha := MAX (alpha, MIN-VALUE (state, game, alpha, beta)) if alpha >= beta then return betaendreturn alphafunction MIN-VALUE (state, game, alpha, beta)if CUTOFF-TEST (state) then return EVAL (state)for each s in SUCCESSORS (state) do beta := MIN (beta, MAX-VALUE (s, game, alpha, beta)) if beta <= alpha then return alphaendreturn betaEffectiveness of


View Full Document

UMBC CMSC 671 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?