Game Search Constrained Search CMSC 25000 Artificial Intelligence

  • Slides: 34
Download presentation
Game Search & Constrained Search CMSC 25000 Artificial Intelligence January 18, 2005

Game Search & Constrained Search CMSC 25000 Artificial Intelligence January 18, 2005

Roadmap I • Searching for the right move – Review adversial search, minimax –

Roadmap I • Searching for the right move – Review adversial search, minimax – Alpha-beta pruning, optimality – State-of-the-art: Specialized techniques – Dealing with chance

Games as Search • Nodes = Board Positions • Each ply (depth + 1)

Games as Search • Nodes = Board Positions • Each ply (depth + 1) = Move • Special feature: – Two players, adversial • Static evaluation function – Instantaneous assessment of board configuration – NOT perfect (maybe not even very good)

Minimax Search

Minimax Search

Minimax Analysis • Complete: – Yes, if finite tree • Optimal: – Yes, if

Minimax Analysis • Complete: – Yes, if finite tree • Optimal: – Yes, if optimal opponent • Time: – b^m • Space: – bm (progressive deepening DFS) • Practically: Chess: b~35, m~100 – Complete solution is impossible • ~2. 5*10^154

Alpha-Beta Pruning • Alpha-beta principle: If you know it’s bad, don’t waste time finding

Alpha-Beta Pruning • Alpha-beta principle: If you know it’s bad, don’t waste time finding out HOW bad • May eliminate some static evaluations • May eliminate some node expansions

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Procedure If level=TOP_LEVEL, alpha = NEGMAX; beta= POSMAX If (reached Search-limit), compute &

Alpha-Beta Procedure If level=TOP_LEVEL, alpha = NEGMAX; beta= POSMAX If (reached Search-limit), compute & return static value of current If level is minimizing level, While more children to explore AND alpha < beta ab = alpha-beta(child) if (ab < beta), then beta = ab Report beta If level is maximizing level, While more children to explore AND alpha < beta ab = alpha-beta(child) if (ab > alpha), then alpha = ab Report alpha

Alpha-Beta Pruning Analysis • Worst case: – Bad ordering: Alpha-beta prunes NO nodes •

Alpha-Beta Pruning Analysis • Worst case: – Bad ordering: Alpha-beta prunes NO nodes • Best case: – Assume cooperative oracle orders nodes • Best value on left • “If an opponent has some response that makes move bad no matter what the moving player does, then the move is bad. ” • Implies: check move where opposing player has choice, check all own moves

Optimal Alpha-Beta Ordering 1 2 5 6 3 7 8 4 9 10 11

Optimal Alpha-Beta Ordering 1 2 5 6 3 7 8 4 9 10 11 12 13 141516 171819 202122 232425 262728 293031 323334 353637 383940 14 15 16 17 18 19 20 21 22 13 14 15 26 27 28 29 30 31 13 14 15 35 36 37 38 39 40

Optimal Ordering Alpha-Beta • Significant reduction of work: – 11 of 27 static evaluations

Optimal Ordering Alpha-Beta • Significant reduction of work: – 11 of 27 static evaluations • Lower bound on # of static evaluations: – if d is even, s = 2*b^d/2 -1 – if d is odd, s = b^(d+1)/2+b^(d-1)/2 -1 • Upper bound on # of static evaluations: – b^d • Reality: somewhere between the two – Typically closer to best than worst

Heuristic Game Search • Handling time pressure – Focus search – Be reasonably sure

Heuristic Game Search • Handling time pressure – Focus search – Be reasonably sure “best” option found is likely to be a good option. • Progressive deepening – Always having a good move ready • Singular extensions – Follow out stand-out moves

Singular Extensions • Problem: Explore to some depth, but things change a lot in

Singular Extensions • Problem: Explore to some depth, but things change a lot in next ply – False sense of security – aka “horizon effect” • Solution: “Singular extensions” – If static value stands out, follow it out – Typically, “forced” moves: • E. g. follow out captures

Additional Pruning Heuristics • Tapered search: – Keep more branches for higher ranked children

Additional Pruning Heuristics • Tapered search: – Keep more branches for higher ranked children • Rank nodes cheaply • Rule out moves that look bad • Problem: – Heuristic: May be misleading • Could miss good moves

Deterministic Games Due to Russell and Norvig

Deterministic Games Due to Russell and Norvig

Games with Chance • Many games mix chance and strategy – E. g. Backgammon

Games with Chance • Many games mix chance and strategy – E. g. Backgammon – Combine dice rolls + opponent moves • Modeling chance in game tree – For each ply, add another ply of “chance nodes” – Represent alternative rolls of dice • One branch per roll • Associate probability of roll with branch

Expectiminimax: Minimax+Chance • Adding chance to minimax – For each roll, compute max/min as

Expectiminimax: Minimax+Chance • Adding chance to minimax – For each roll, compute max/min as before • Computing values at chance nodes – Calculate EXPECTED value – Sum of branches • Weight by probability of branch

Expecti… Tree

Expecti… Tree

Summary • Game search: – Key features: Alternating, adversarial moves • Minimax search: Models

Summary • Game search: – Key features: Alternating, adversarial moves • Minimax search: Models adversarial game • Alpha-beta pruning: – If a branch is bad, don’t need to see how bad! – Exclude branch once know can’t change value – Can significantly reduce number of evaluations • Heuristics: Search under pressure – Progressive deepening; Singular extensions

Constraint Propagation Artificial Intelligence CMSC 25000 January 18, 2005

Constraint Propagation Artificial Intelligence CMSC 25000 January 18, 2005

Agenda • Constraint Propagation: Motivation • Constraint Propagation Example – Waltz line labeling •

Agenda • Constraint Propagation: Motivation • Constraint Propagation Example – Waltz line labeling • Constraint Propagation Mechanisms – Arc consistency – CSP as search • Forward-checking • Back-jumping • Summary

Leveraging Representation • General search problems encode taskspecific knowledge – Successor states, goal tests,

Leveraging Representation • General search problems encode taskspecific knowledge – Successor states, goal tests, state structure – “black box” wrt to search algorithm • Constraint satisfaction fixes representation – Variables, values, constraints – Allows more efficient, structure-specific search

Constraint Satisfaction Problems • Very general: Model wide range of tasks • Key components:

Constraint Satisfaction Problems • Very general: Model wide range of tasks • Key components: – Variables: Take on a value – Domains: Values that can be assigned to vars – Constraints: Restrictions on assignments • Constraints are HARD – Not preferences: Must be observed • E. g. Can’t schedule two classes: same room, same time

Constraint Satisfaction Problem • Graph/Map Coloring: Label a graph such that no two adjacent

Constraint Satisfaction Problem • Graph/Map Coloring: Label a graph such that no two adjacent vertexes same color – Variables: Vertexes – Domain: Colors – Constraints: If E(a, b), then C(a) != C(b)

Constraint Satisfaction Problems • Resource Allocation: – Scheduling: N classes over M terms, 4

Constraint Satisfaction Problems • Resource Allocation: – Scheduling: N classes over M terms, 4 classes/term – Aircraft at airport gates • Satisfiability: e. g. 3 -SAT – Assignments of truth values to variables such that 1) consistent and 2) clauses true

Constraint Satisfaction Problem • “N-Queens”: – Place N queens on an Nx. N chessboard

Constraint Satisfaction Problem • “N-Queens”: – Place N queens on an Nx. N chessboard such that none attacks another – Variables: Queens (1/column) – Domain: Rows – Constraints: Not same row, column, or diagonal

N-queens Q 3 Q 1 Q 4 Q 2

N-queens Q 3 Q 1 Q 4 Q 2

Constraint Satisfaction Problem • Range of tasks: – Coloring, Resource Allocation, Satisfiability – Varying

Constraint Satisfaction Problem • Range of tasks: – Coloring, Resource Allocation, Satisfiability – Varying complexity: E. g. 3 -SAT NP-complete • Complexity: Property of problem NOT CSP • Basic Structure: – Variables: Graph nodes, Classes, Boolean vars – Domains: Colors, Time slots, Truth values – Constraints: No two adjacent nodes with same color, • No two classes in same time, consistent, satisfying ass’t

Problem Characteristics • Values: – Finite? Infinite? Real? • Discrete vs Continuous • Constraints

Problem Characteristics • Values: – Finite? Infinite? Real? • Discrete vs Continuous • Constraints – Unary? Binary? N-ary? • Note: all higher order constraints can be reduced to binary

Representational Advantages • Simple goal test: – Complete, consistent assignment • Complete: All variables

Representational Advantages • Simple goal test: – Complete, consistent assignment • Complete: All variables have a value • Consistent: No constraints violates • Maximum depth? – Number of variables • Search order? – Commutative, reduces branching – Strategy: Assign value to one variable at a time