CS 188: Artificial Intelligence Fall Announcements

Similar documents
Announcements. CS 188: Artificial Intelligence Fall Adversarial Games. Computing Minimax Values. Evaluation Functions. Recap: Resource Limits

Announcements. CS 188: Artificial Intelligence Spring Mini-Contest Winners. Today. GamesCrafters. Adversarial Games

Evaluation for Pacman. CS 188: Artificial Intelligence Fall Iterative Deepening. α-β Pruning Example. α-β Pruning Pseudocode.

CS 188: Artificial Intelligence Fall 2008

CSE 573: Artificial Intelligence

CS 188: Artificial Intelligence

Minimax strategies, alpha beta pruning. Lirong Xia

CS 4100 // artificial intelligence. Recap/midterm review!

CS 188 Introduction to Fall 2007 Artificial Intelligence Midterm

CS 188: Artificial Intelligence Spring 2007

CS 188: Artificial Intelligence Spring Today

Announcements. CS 188: Artificial Intelligence Spring Probability recap. Outline. Bayes Nets: Big Picture. Graphical Model Notation

Algorithms for Playing and Solving games*

Game playing. Chapter 6. Chapter 6 1

Final. Introduction to Artificial Intelligence. CS 188 Spring You have approximately 2 hours and 50 minutes.

Adversarial Search & Logic and Reasoning

Today s Outline. Recap: MDPs. Bellman Equations. Q-Value Iteration. Bellman Backup 5/7/2012. CSE 473: Artificial Intelligence Reinforcement Learning

CS 188: Artificial Intelligence Spring Announcements

IS-ZC444: ARTIFICIAL INTELLIGENCE

Probabilistic Models. Models describe how (a portion of) the world works

CS 188: Artificial Intelligence Fall 2009

CSE 473: Artificial Intelligence Autumn 2011

CS 188: Artificial Intelligence Spring Announcements

Alpha-Beta Pruning: Algorithm and Analysis

Introduction to Fall 2008 Artificial Intelligence Midterm Exam

Bayesian Networks. Vibhav Gogate The University of Texas at Dallas

CSE 473: Artificial Intelligence

CS188: Artificial Intelligence, Fall 2009 Written 2: MDPs, RL, and Probability

Introduction to Spring 2006 Artificial Intelligence Practice Final

Summary. Agenda. Games. Intelligence opponents in game. Expected Value Expected Max Algorithm Minimax Algorithm Alpha-beta Pruning Simultaneous Game

Using first-order logic, formalize the following knowledge:

CSE 473: Artificial Intelligence Spring 2014

Bayesian Networks. Vibhav Gogate The University of Texas at Dallas

CS 188: Artificial Intelligence. Our Status in CS188

CS 188: Artificial Intelligence Spring Announcements

Alpha-Beta Pruning: Algorithm and Analysis

CSL302/612 Artificial Intelligence End-Semester Exam 120 Minutes

Decision Theory: Q-Learning

Weighted Majority and the Online Learning Approach

Outline. CSE 573: Artificial Intelligence Autumn Agent. Partial Observability. Markov Decision Process (MDP) 10/31/2012

Final. CS 188 Fall Introduction to Artificial Intelligence

Alpha-Beta Pruning: Algorithm and Analysis

Announcements. CS 188: Artificial Intelligence Fall Markov Models. Example: Markov Chain. Mini-Forward Algorithm. Example

CMSC 474, Game Theory

CS 188: Artificial Intelligence

CS 188 Introduction to AI Fall 2005 Stuart Russell Final

An AI-ish view of Probability, Conditional Probability & Bayes Theorem

10/18/2017. An AI-ish view of Probability, Conditional Probability & Bayes Theorem. Making decisions under uncertainty.

Adversarial Search. Christos Papaloukas, Iosif Angelidis. University of Athens November 2017

CS 188: Artificial Intelligence Fall 2011

CSE 473: Artificial Intelligence Autumn Topics

CS 343: Artificial Intelligence

Probabilistic Reasoning

Our Status. We re done with Part I Search and Planning!

CS221 Practice Midterm

Discrete Probability and State Estimation

CS 570: Machine Learning Seminar. Fall 2016

CS221 Practice Midterm #2 Solutions

Notes on induction proofs and recursive definitions

Outline. CSE 573: Artificial Intelligence Autumn Bayes Nets: Big Picture. Bayes Net Semantics. Hidden Markov Models. Example Bayes Net: Car

CS 188: Artificial Intelligence Spring Announcements

Final. Introduction to Artificial Intelligence. CS 188 Spring You have approximately 2 hours and 50 minutes.

CS 188: Artificial Intelligence Fall 2009

Outline. CSE 473: Artificial Intelligence Spring Bayes Nets: Big Picture. Bayes Net Semantics. Hidden Markov Models. Example Bayes Net: Car

CS 188: Artificial Intelligence Fall 2008

General Naïve Bayes. CS 188: Artificial Intelligence Fall Example: Overfitting. Example: OCR. Example: Spam Filtering. Example: Spam Filtering

CS 188: Artificial Intelligence Fall 2008

CS 188: Artificial Intelligence Spring Announcements

CS 361: Probability & Statistics

Reinforcement Learning Wrap-up

CSE 473: Ar+ficial Intelligence. Hidden Markov Models. Bayes Nets. Two random variable at each +me step Hidden state, X i Observa+on, E i

The exam is closed book, closed calculator, and closed notes except your one-page crib sheet.

Probability Hal Daumé III. Computer Science University of Maryland CS 421: Introduction to Artificial Intelligence 27 Mar 2012

CSEP 573: Artificial Intelligence

CS 188: Artificial Intelligence Fall 2011

Errors, and What to Do. CS 188: Artificial Intelligence Fall What to Do About Errors. Later On. Some (Simplified) Biology

CS 188: Artificial Intelligence Spring Announcements

Bayes Nets III: Inference

CS 380: ARTIFICIAL INTELLIGENCE

CS 188: Artificial Intelligence Spring 2009

CS 188: Artificial Intelligence

Uncertain Knowledge and Bayes Rule. George Konidaris

Sampling from Bayes Nets

CS 188: Artificial Intelligence. Outline

Final. CS 188 Fall Introduction to Artificial Intelligence

CS 5522: Artificial Intelligence II

Reasoning under Uncertainty: Intro to Probability

Decision Theory: Markov Decision Processes

CSE 473: Artificial Intelligence Probability Review à Markov Models. Outline

CS 343: Artificial Intelligence

Reasoning Under Uncertainty: Introduction to Probability

Markov Decision Processes

Don t Plan for the Unexpected: Planning Based on Plausibility Models

Introduction to Fall 2011 Artificial Intelligence Final Exam

Reasoning Under Uncertainty: Introduction to Probability

Approximate Q-Learning. Dan Weld / University of Washington

Announcements. CS 188: Artificial Intelligence Fall Causality? Example: Traffic. Topology Limits Distributions. Example: Reverse Traffic

Decision Theory Intro: Preferences and Utility

CS188: Artificial Intelligence, Fall 2009 Written 2: MDPs, RL, and Probability

Introduction to Fall 2009 Artificial Intelligence Final Exam

Transcription:

CS 188: Artificial Intelligence Fall 2009 Lecture 7: Expectimax Search 9/17/2008 Dan Klein UC Berkeley Many slides over the course adapted from either Stuart Russell or Andrew Moore 1 Announcements Written 1: Search and CSPs is up Project 2: Multi-agent Search is up Want a partner? Come to the front after lecture Guesses at future project dates on lectures page Yes, class and section on 9/24 1

Adversarial Games Deterministic, zero-sum games: Tic-tac-toe, chess, checkers One player maximizes result The other minimizes result Minimax search: A state-space search tree Players alternate turns Each node has a minimax value: best achievable utility against a rational adversary Minimax values: computed recursively 5 max 2 5 8 2 5 6 Terminal values: part of the game min 3 Computing Minimax Values Two recursive functions: max-value maxes the values of successors min-value mins the values of successors def value(state): If the state is a terminal state: return the state s utility If the next agent is MAX: return max-value(state) If the next agent is MIN: return min-value(state) def max-value(state): Initialize max = - For each successor of state: Compute value(successor) Update max accordingly Return max 2

Recap: Resource Limits Cannot search to leaves Depth-limited search Instead, search a limited depth of tree Replace terminal utilities with an eval function for nonterminal positions 4 max -2 min 4 min -1-2 4 9 Guarantee of optimal play is gone Replanning agents: Search to choose next action Replan each new turn in response to new state???? 5 Evaluation Functions Function which scores non-terminals Ideal function: returns the utility of the position In practice: typically weighted linear sum of features: e.g. f 1 (s) = (num white queens num black queens), etc. 6 3

Evaluation for Pacman [DEMO: thrashing, smart ghosts] 7 Why Pacman Starves He knows his score will go up by eating the dot now He knows his score will go up just as much by eating the dot later on There are no point-scoring opportunities after eating the dot Therefore, waiting seems just as good as eating 4

Iterative Deepening Iterative deepening uses DFS as a subroutine: 1. Do a DFS which only searches for paths of length 1 or less. (DFS gives up on any path of length 2) 2. If 1 failed, do a DFS which only searches paths of length 2 or less. 3. If 2 failed, do a DFS which only searches paths of length 3 or less..and so on. b Why do we want to do this for multiplayer games? Note: wrongness of eval functions matters less and less the deeper the search goes! [DEMO: depth limited] 9 Pruning for Minimax 10 5

Pruning in Minimax Search 3 12 8 2 14 5 2 11 Pruning in Minimax Search [-,+ ] [3,+ ] [3,14] [3,5] [3,3] [-,3] [3,3] [-,2] [-,14] [-,5] [2,2] 3 12 8 2 14 5 2 12 6

Alpha-Beta Pruning General configuration We re computing the MIN- VALUE at n MAX We re looping over n s children n s value estimate is dropping a is the best value that MAX can get at any choice point along the current path If n becomes worse than a, MAX will avoid it, so can stop considering n s other children Define b similarly for MIN MIN MAX MIN a n 13 Alpha-Beta Pseudocode b v 7

Alpha-Beta Pruning Example 3 3 2 1 3 12 2 14 5 1 8 8 a is MAX s best alternative here or above b is MIN s best alternative here or above Alpha-Beta Pruning Example Starting a/b a=- b=+ 3 Raising a a=- b=+ a=3 b=+ a=3 b=+ a=3 b=+ Lowering b 3 2 1 a=- b=+ a=- b=3 a=- b=3 a=- b=3 a=3 b=+ a=3 b=2 a=3 b=+ a=3 a=3 b=14 b=5 3 12 2 14 5 1 a=3 b=1 8 Raising a a=- b=3 8 a=8 b=3 a is MAX s best alternative here or above b is MIN s best alternative here or above 8

Alpha-Beta Pruning Properties This pruning has no effect on final result at the root Values of intermediate nodes might be wrong! Good child ordering improves effectiveness of pruning With perfect ordering : Time complexity drops to O(b m/2 ) Doubles solvable depth! Full search of, e.g. chess, is still hopeless This is a simple example of metareasoning (computing about what to compute) 17 Expectimax Search Trees What if we don t know what the result of an action will be? E.g., In solitaire, next card is unknown In minesweeper, mine locations In pacman, the ghosts act randomly Can do expectimax search Chance nodes, like min nodes, except the outcome is uncertain Calculate expected utilities Max nodes as in minimax search Chance nodes take average (expectation) of value of children Later, we ll learn how to formalize the underlying problem as a Markov Decision Process max 10 4 5 7 [DEMO: minvsexp] chance 18 9

Maximum Expected Utility Why should we average utilities? Why not minimax? Principle of maximum expected utility: an agent should chose the action which maximizes its expected utility, given its knowledge General principle for decision making Often taken as the definition of rationality We ll see this idea over and over in this course! Let s decompress this definition 19 Reminder: Probabilities A random variable represents an event whose outcome is unknown A probability distribution is an assignment of weights to outcomes Example: traffic on freeway? Random variable: T = whether there s traffic Outcomes: T in {none, light, heavy} Distribution: P(T=none) = 0.25, P(T=light) = 0.55, P(T=heavy) = 0.20 Some laws of probability (more later): Probabilities are always non-negative Probabilities over all possible outcomes sum to one As we get more evidence, probabilities may change: P(T=heavy) = 0.20, P(T=heavy Hour=8am) = 0.60 We ll talk about methods for reasoning and updating probabilities later 20 10

What are Probabilities? Objectivist / frequentist answer: Averages over repeated experiments E.g. empirically estimating P(rain) from historical observation Assertion about how future experiments will go (in the limit) New evidence changes the reference class Makes one think of inherently random events, like rolling dice Subjectivist / Bayesian answer: Degrees of belief about unobserved variables E.g. an agent s belief that it s raining, given the temperature E.g. pacman s belief that the ghost will turn left, given the state Often learn probabilities from past experiences (more later) New evidence updates beliefs (more later) 21 Uncertainty Everywhere Not just for games of chance! I m sick: will I sneeze this minute? Email contains FREE! : is it spam? Tooth hurts: have cavity? 60 min enough to get to the airport? Robot rotated wheel three times, how far did it advance? Safe to cross street? (Look both ways!) Sources of uncertainty in random variables: Inherently random process (dice, etc) Insufficient or weak evidence Ignorance of underlying processes Unmodeled variables The world s just noisy it doesn t behave according to plan! Compare to fuzzy logic, which has degrees of truth, rather than just degrees of belief 22 11

Reminder: Expectations We can define function f(x) of a random variable X The expected value of a function is its average value, weighted by the probability distribution over inputs Example: How long to get to the airport? Length of driving time as a function of traffic: L(none) = 20, L(light) = 30, L(heavy) = 60 What is my expected driving time? Notation: E[ L(T) ] Remember, P(T) = {none: 0.25, light: 0.5, heavy: 0.25} E[ L(T) ] = L(none) * P(none) + L(light) * P(light) + L(heavy) * P(heavy) E[ L(T) ] = (20 * 0.25) + (30 * 0.5) + (60 * 0.25) = 35 23 Expectations Real valued functions of random variables: Expectation of a function of a random variable Example: Expected value of a fair die roll X P f 1 1/6 1 2 1/6 2 3 1/6 3 4 1/6 4 5 1/6 5 6 1/6 6 24 12

Utilities Utilities are functions from outcomes (states of the world) to real numbers that describe an agent s preferences Where do utilities come from? In a game, may be simple (+1/-1) Utilities summarize the agent s goals Theorem: any set of preferences between outcomes can be summarized as a utility function (provided the preferences meet certain conditions) In general, we hard-wire utilities and let actions emerge (why don t we let agents decide their own utilities?) More on utilities soon 25 Expectimax Search In expectimax search, we have a probabilistic model of how the opponent (or environment) will behave in any state Model could be a simple uniform distribution (roll a die) Model could be sophisticated and require a great deal of computation We have a node for every outcome out of our control: opponent or environment The model might say that adversarial actions are likely! For now, assume for any state we magically have a distribution to assign probabilities to opponent actions / environment outcomes Having a probabilistic belief about an agent s action does not mean that agent is flipping any coins! 26 13

Expectimax Pseudocode def value(s) if s is a max node return maxvalue(s) if s is an exp node return expvalue(s) if s is a terminal node return evaluation(s) def maxvalue(s) values = [value(s ) for s in successors(s)] return max(values) 8 4 5 6 def expvalue(s) values = [value(s ) for s in successors(s)] weights = [probability(s, s ) for s in successors(s)] return expectation(values, weights) 27 Expectimax for Pacman Notice that we ve gotten away from thinking that the ghosts are trying to minimize pacman s score Instead, they are now a part of the environment Pacman has a belief (distribution) over how they will act Quiz: Can we see minimax as a special case of expectimax? Quiz: what would pacman s computation look like if we assumed that the ghosts were doing 1-ply minimax and taking the result 80% of the time, otherwise moving randomly? If you take this further, you end up calculating belief distributions over your opponents belief distributions over your belief distributions, etc Can get unmanageable very quickly! 28 14

Expectimax for Pacman Results from playing 5 games [demo: world assumptions] Minimax Pacman Expectimax Pacman Minimizing Ghost Won 5/5 Avg. Score: 493 Won 1/5 Avg. Score: -303 Random Ghost Won 5/5 Avg. Score: 483 Won 5/5 Avg. Score: 503 Pacman used depth 4 search with an eval function that avoids trouble Ghost used depth 2 search with an eval function that seeks Pacman Expectimax Pruning? 30 15

Expectimax Evaluation For minimax search, evaluation function scale doesn t matter We just want better states to have higher evaluations (get the ordering right) We call this property insensitivity to monotonic transformations For expectimax, we need the magnitudes to be meaningful as well E.g. must know whether a 50% / 50% lottery between A and B is better than 100% chance of C 100 or -10 vs 0 is different than 10 or -100 vs 0 31 E.g. Backgammon Expectiminimax Mixed Layer Types Environment is an extra player that moves after each agent Chance nodes take expectations, otherwise like minimax 32 16

Stochastic Two-Player Dice rolls increase b: 21 possible rolls with 2 dice Backgammon 20 legal moves Depth 4 = 20 x (21 x 20) 3 1.2 x 10 9 As depth increases, probability of reaching a given node shrinks So value of lookahead is diminished So limiting depth is less damaging But pruning is less possible TDGammon uses depth-2 search + very good eval function + reinforcement learning: worldchampion level play 33 Non-Zero-Sum Games Similar to minimax: Utilities are now tuples Each player maximizes their own entry at each node Propagate (or back up) nodes from children Can give rise to cooperation and competition dynamically 1,2,6 4,3,2 6,1,2 7,4,1 5,1,1 1,5,2 7,7,1 5,4,5 34 17