Hoe schaakt een computer? Arnold Meijster. Why study games? Fun Historically major subject in AI Interesting subject of study because they are hard Games.

Slides:



Advertisements
Similar presentations
Chapter 6, Sec Adversarial Search.
Advertisements

Adversarial Search Chapter 6 Sections 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Artificial Intelligence 1: game playing Lecturer: Tom Lenaerts SWITCH, Vlaams Interuniversitair Instituut voor Biotechnologie.
Adversarial Search Chapter 6 Section 1 – 4. Types of Games.
Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Games & Adversarial Search
Games and adversarial search
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
CS 484 – Artificial Intelligence
Adversarial Search Chapter 6 Section 1 – 4.
Adversarial Search Chapter 5.
1 Game Playing. 2 Outline Perfect Play Resource Limits Alpha-Beta pruning Games of Chance.
Adversarial Search: Game Playing Reading: Chapter next time.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Adversarial Search CSE 473 University of Washington.
Adversarial Search Chapter 6.
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
An Introduction to Artificial Intelligence Lecture VI: Adversarial Search (Games) Ramin Halavati In which we examine problems.
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
EIE426-AICV 1 Game Playing Filename: eie426-game-playing-0809.ppt.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
Game Playing CSC361 AI CSC361: Game Playing.
Games and adversarial search
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Ch.6: Adversarial Search Fall 2008 Marco Valtorta.
1 search CS 331/531 Dr M M Awais A* Examples:. 2 search CS 331/531 Dr M M Awais 8-Puzzle f(N) = g(N) + h(N)
Game Tree Search based on Russ Greiner and Jean-Claude Latombe’s notes.
Adversarial Search: Game Playing Reading: Chess paper.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
Game Playing State-of-the-Art  Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in Used an endgame database defining.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Notes adapted from lecture notes for CMSC 421 by B.J. Dorr
Adversarial Search Chapter 5 Adapted from Tom Lenaerts’ lecture notes.
PSU CS 370 – Introduction to Artificial Intelligence Game MinMax Alpha-Beta.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
Game Playing.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Game-playing AIs Part 1 CIS 391 Fall CSE Intro to AI 2 Games: Outline of Unit Part I (this set of slides)  Motivation  Game Trees  Evaluation.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Instructor: Vincent Conitzer
1 Adversarial Search CS 171/271 (Chapter 6) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Adversarial Search Chapter 6 Section 1 – 4. Search in an Adversarial Environment Iterative deepening and A* useful for single-agent search problems What.
Paula Matuszek, CSC 8520, Fall Based in part on aima.eecs.berkeley.edu/slides-ppt 1 CS 8520: Artificial Intelligence Adversarial Search Paula Matuszek.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Turn-Based Games Héctor Muñoz-Avila sources: Wikipedia.org Russell & Norvig AI Book; Chapter 5 (and slides)
Adversarial Search Chapter 6 Section 1 – 4. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Adversarial Search Chapter 5 Sections 1 – 4. AI & Expert Systems© Dr. Khalid Kaabneh, AAU Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
ADVERSARIAL SEARCH Chapter 6 Section 1 – 4. OUTLINE Optimal decisions α-β pruning Imperfect, real-time decisions.
Adversarial Search CMPT 463. When: Tuesday, April 5 3:30PM Where: RLC 105 Team based: one, two or three people per team Languages: Python, C++ and Java.
5/4/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 9, 5/4/2005 University of Washington, Department of Electrical Engineering Spring 2005.
Artificial Intelligence AIMA §5: Adversarial Search
Game Playing Why do AI researchers study game playing?
Adversarial Search and Game-Playing
EA C461 – Artificial Intelligence Adversarial Search
Adversarial Search Chapter 5.
Games & Adversarial Search
Games & Adversarial Search
Adversarial Search.
Games & Adversarial Search
Game Playing Fifth Lecture 2019/4/11.
Games & Adversarial Search
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Hoe schaakt een computer? Arnold Meijster

Why study games? Fun Historically major subject in AI Interesting subject of study because they are hard Games are of interest for AI researchers Solution is a strategy (strategy specifies move for every possible opponent reply). Time limits force an approximate solution Evaluation function: evaluate “goodness” of game position Examples: chess, checkers, othello/reversi, backgammon, poker, bridge

Game setup Two players: MAX and MIN MAX moves first and they take turns until the game is over. Another view: games are a search problem Initial state: e.g. board configuration of chess Successor function: list of (move,state) pairs specifying legal moves. Goal/Terminal test: Is the game finished? Utility function: Gives numerical value of terminal states. E.g. win (+1), loose (-1) and draw (0) MAX uses a search tree to determine next move.

(Partial) Game Tree for Tic-Tac-Toe

Optimal strategies Assumption: Both players play optimally !! Find the strategy for MAX assuming an infallible MIN opponent. Given a game tree, the optimal strategy can be determined by computing the minimax value of each node of the tree: MINIMAX-VALUE(n)= UTILITY(n)If n is a terminal max s  successors(n) MINIMAX-VALUE(s) If n is a max node min s  successors(n) MINIMAX-VALUE(s) If n is a min node

MinMax – First Example Max’s turn Max’s turn Would like the “9” points (the maximum) Would like the “9” points (the maximum) But if Max chooses the left branch, Min will choose the move to get 3 But if Max chooses the left branch, Min will choose the move to get 3  left branch has a value of 3 If Max chooses right, Min can choose any one of 5, 6 or 7 (will choose 5, the minimum) If Max chooses right, Min can choose any one of 5, 6 or 7 (will choose 5, the minimum)  right branch has a value of 5 Right branch is largest (the maximum) so choose that move Right branch is largest (the maximum) so choose that move Max Min Max

MinMax – Second Example

Tic-Tac-Toe: Three-Ply Game Tree

MinMax – Pseudo Code int Max() { int best = -INFINITY; /* first move is best */ if (isTerminalState()) return Evaluate(); GenerateLegalMoves(); while (MovesLeft()) { MakeNextMove(); val = Min(); /* Min’s turn next */ UnMakeMove(); if (val > best) best = val; } return best; }

MinMax – Pseudo Code int Min() { int best = INFINITY; /*  differs from MAX */ if (isTerminalState()) return Evaluate(); GenerateLegalMoves(); while (MovesLeft()) { MakeNextMove(); val = Max(); /* Max’s turn next */ UnMakeMove(); if (val < best) //  different than MAX best = val; } return best; }

Problem of minimax search Number of game states explodes when the number of moves increases. Solution: Do not examine every node Idea: stop evaluating moves when you find a worse result than the previously examined moves.  Does not benefit the player to play that move, it need not be evaluated any further.  Save processing time without affecting final result

α is the value of the best (i.e., highest-value) choice found so far at any choice point along the path for max If v is worse than α, max will avoid it   prune that branch Define β similarly for min The α-β pruning algorithm

MinMax – AlphaBeta Pruning Example From Max’s point of view, 1 is already lower than 4 or 5, so no need to evaluate 2 and 3 (bottom right)  Prune From Max’s point of view, 1 is already lower than 4 or 5, so no need to evaluate 2 and 3 (bottom right)  Prune

Minimax: 2-ply deep

α-β pruning example

Properties of α-β Pruning does not affect final result (same as minimax) Good move ordering improves effectiveness of pruning With "perfect ordering," time complexity = O(b m/2 ) Branching factor of sqrt(b) !! Alpha-beta pruning can look twice as far as minimax in the same amount of time Chess: 4-ply lookahead is a hopeless chess player! 4-ply ≈ human novice 8-ply ≈ typical PC, human master 12-ply ≈ Deep Blue, Kasparov Optimization: repeated states are possible. Store them in memory = transposition table

MiniMax and Chess With a complete tree, we can determine the best possible move With a complete tree, we can determine the best possible move However, a complete tree is impossible for chess! However, a complete tree is impossible for chess! At a given time, chess has ~ 35 legal moves. At a given time, chess has ~ 35 legal moves. 35 at one ply, 35 2 = 1225 at two plies … 35 6 = 2 billion and = 2 quadrillion 35 at one ply, 35 2 = 1225 at two plies … 35 6 = 2 billion and = 2 quadrillion Games last 40 moves (or more), so Games last 40 moves (or more), so For large games (like Chess) we can’t see the end of the game. For large games (like Chess) we can’t see the end of the game.

Games of imperfect information SHANNON (1950): Cut off search earlier (replace TERMINAL-TEST by CUTOFF-TEST) Apply heuristic evaluation function EVAL (replacing utility function of alpha-beta)

Heuristic EVAL Idea: produce an estimate of the expected utility of the game from a given position. Performance depends on quality of EVAL. Requirements: Computation should not take too long. For non-terminal states the EVAL should be strongly correlated with the actual chance of winning. Only useful for quiescent (no wild swings in value in near future) states Requires quiescence search

Evaluation functions Typically a linear weighted sum of features Eval(s) = w 1 f 1 (s) + w 2 f 2 (s) + … + w n f n (s) e.g., w 1 = 10 with f 1 (s) = (number of white queens) – (number of black queens), etc. Rule of thumb weight values for chess: Pawn=1 Bishop, Knight=3 Rook=5 Queen=10 King=

Heuristic difficulties Heuristic counts pieces won! Consider two cases: 1)Black to play 2)White to play It really makes a difference when to apply the evaluation function!!!

Horizon effect A program with a fixed depth search less than 14 will think it can avoid the queening move

Horizon effect

Mate in 19!

Mate in 40! Source: Mate in 40 with Ke7. Worse are Kc5, Kc6, Kd5, Kd7, Ke5 and Ke6 which throw away the win.

Mate in 39! White mates in 39 after Ng7. Worse are: Kg4: white mates in 16 Kg5, Kg6, Kh4: white mates in 15 Kh6: white mates in 13 Nc7, Nd6: white mates in 12 Nf6: white mates in 10.

Mate (in 0)

Mate (in 1)

Mate (in 0)

Mate (in 1)

Previous states (black to move)

Nalimov dbase: backward search for all mate-in-n-positions do for all reverse moves m by black do if move m leads (forced) to mate in n then determine all mate in n+1 positions

Endgame databases…

How end game databases changed chess All 5 piece endgames solved (can have > 10^8 states) & many 6 piece All 5 piece endgames solved (can have > 10^8 states) & many 6 piece KRBKNN (~10^11 states): longest path-to-mate 223 KRBKNN (~10^11 states): longest path-to-mate 223 Rule changes Rule changes Max number of moves from capture/pawn move to completion Max number of moves from capture/pawn move to completion Chess knowledge Chess knowledge KRKN game was thought to be a draw, but KRKN game was thought to be a draw, but White wins in 51% of WTM White wins in 51% of WTM White wins in 87% of BTM White wins in 87% of BTM

Summary Games are fun They illustrate several important points about AI Perfection is unattainable -> approximation Uncertainty constrains the assignment of values to states A computer’s strength at chess comes from: A computer’s strength at chess comes from: How deep can it search How deep can it search How well can it evaluate a board position How well can it evaluate a board position In some sense, like humans – a chess grandmaster can evaluate positions better and can look further ahead In some sense, like humans – a chess grandmaster can evaluate positions better and can look further ahead Games are to AI as grand prix racing is to automobile design.