Unformatted text preview:

Game Playing: Adversarial SearchWhy study gamesTypical Case (perfect games)How to play a gameGame TreesSlide 6Evaluation FunctionSlide 8An example (partial) game tree for Tic-Tac-ToeSome Chess Positions and their EvaluationsMinimax RuleMinimax TreeMinimax procedureMinimax SearchComments on Minimax searchAlpha-beta pruningSlide 17Slide 18Alpha-beta searchAlpha-beta algorithmEffectiveness of Alpha-beta pruningAn example of Alpha-beta pruningFinal treeGame Playing: Game Playing: Adversarial SearchAdversarial SearchChapter 6Why study games•Fun•Clear criteria for success•Interesting, hard problems which require minimal “initial structure”•Games often define very large search spaces–chess 10*120 nodes•Historical reasons•Offer an opportunity to study problems involving {hostile, adversarial, competing} agents.•Different from games studied in game theoryTypical Case (perfect games)•2-person game•Players alternate moves •Zero-sum-- one players 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 •Clear rules for legal moves (no uncertain position transition involved)•Well-defined outcomes (W/L/D)•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.–Each move leads to a new board configuration (position).–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 position–Look aheadGame Trees•Problem spaces for typical games represented as trees.•Root node represents the “board” configuration at which a decision must be made as to what is the best single move to make next. (not necessarily the initial configuration)•Evaluator function rates a board position. f(board) (a real number). •Arcs represent the possible legal moves for a player (no costs associates to arcs•Terminal nodes represent end-game configurations (the result must be one of “win”, “lose”, and “draw”, possibly with numerical payoff)•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+1 •Complete game tree: includes all configurations that can be generated from the root by legal moves (all leaves are terminal nodes)•Incomplete game tree: includes all configurations that can be generated from the root by legal moves to a given depth (looking ahead to a given steps)Evaluation Function•Evaluation function or static evaluator–Evaluates 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) >> 0: win for me. –f(n) << 0: win for you..•Evaluation function is a heuristic function, and it is where the domain experts’ knowledge resides.•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) is sum for black.•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 6,000 features in its evaluation function.An example (partial) 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.Some Chess Positions and their EvaluationsMinimax Rule•Goal of game tree search: to determine one move for Max player that maximizes the guaranteed payoff for a given game tree for MAX Regardless of the moves the MIN will take•The value of each node (Max and MIN) is determined by (back up from) the values of its children•MAX plays the worst case scenario: Always assume MIN to take moves to maximize his pay-off (i.e., to minimize the pay-off of MAX)•For a MAX node, the backed up value is the maximum of the values associated with its children•For a MIN node, the backed up value is the minimum of the values associated with its childrenMinimax TreeMAX nodeMIN nodef value A1 is selected as the next moveMinimax procedure•Create start node as a MAX node with current board configuration •Expand nodes down to some depth (i.e., ply) of lookahead in the game.•Apply the evaluation function at each of the leaf nodes •Obtain the “back up" values for each of the non-leaf nodes from its children by Minimax rule until a value is computed for the root node. •Pick the operator associated with the child node whose backed up value determined the value at the root as the move for MAXMinimax Search2 7 18MAXMIN2 7 18212 7 182 122 7 182 12This is the moveselected by minimaxStatic evaluator valueComments on Minimax search•The search is depth-first with the given depth (ply) as the limit–Time complexity: O(b^d)–Linear space complexity•Performance depends on–Quality of evaluation functions (domain knowledge)–Depth of the search (computer power and search algorithm)•Different from ordinary state space search–Not to search for a complete solution but for one move only–No cost is associated with each arc–MAX does not know how MIN is going to counter each of his moves•Minimax rule is a basis for other game tree search algorithmsAlpha-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


View Full Document

UMBC CMCS 471 - Game Playing: Adversarial Search

Download Game Playing: Adversarial Search
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 Game Playing: Adversarial Search 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 Game Playing: Adversarial Search 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?