Data Structures and Algorithms

Slides:



Advertisements
Similar presentations
Alpha-Beta Search. 2 Two-player games The object of a search is to find a path from the starting position to a goal position In a puzzle-type problem,
Advertisements

1 CS 385 Fall 2006 Chapter 4 Heuristic Search. 2 Heuristics eurisko ("I discover" in Greek) "the study of the methods and rules of discovery and invention."
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.
Adversarial Search Reference: “Artificial Intelligence: A Modern Approach, 3 rd ed” (Russell and Norvig)
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Lecture 12: Revision Lecture Dr John Levine Algorithms and Complexity March 27th 2006.
CHAPTER 10 FUN AND GAMES Group 1: Xiangling Liu.
Tic Tac Toe Architecture CSE 5290 – Artificial Intelligence 06/13/2011 Christopher Hepler.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
Chess AI’s, How do they work? Math Club 10/03/2011.
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)
Adversarial Search: Game Playing Reading: Chess paper.
Alpha-Beta Search. 2 Two-player games The object of a search is to find a path from the starting position to a goal position In a puzzle-type problem,
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Programming & Data Structures
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
Minimax.
AD FOR GAMES Lecture 4. M INIMAX AND A LPHA -B ETA R EDUCTION Borrows from Spring 2006 CS 440 Lecture Slides.
Mark Dunlop, Computer and Information Sciences, Strathclyde University 1 Algorithms & Complexity 5 Games Mark D Dunlop.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Search exploring the consequences of possible actions.
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW AI for games: min-max search COMP #
Game tree search Chapter 6 (6.1 to 6.3 and 6.6) cover games. 6.6 covers state of the art game players in particular. 6.5 covers games that involve uncertainty.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
CompSci Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the.
CMSC 421: Intro to Artificial Intelligence October 6, 2003 Lecture 7: Games Professor: Bonnie J. Dorr TA: Nate Waisbrot.
CPS Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the “right-hand”
Parallel Programming in Chess Simulations Part 2 Tyler Patton.
CPS 100, Spring Search, Backtracking,Heuristics l How do you find a needle in a haystack?  How does a computer play chess?  Why would you write.
Understanding AI of 2 Player Games. Motivation Not much experience in AI (first AI project) and no specific interests/passion that I wanted to explore.
Artificial Intelligence AIMA §5: Adversarial Search
Game playing Types of games Deterministic vs. chance
Adversarial Search and Game-Playing
ADVERSARIAL GAME SEARCH: Min-Max Search
Backtracking, Search, Heuristics
Announcements Homework 1 Full assignment posted..
Instructor: Vincent Conitzer
Data Structures Lab Algorithm Animation.
Last time: search strategies
Intro to Computer Science II
PENGANTAR INTELIJENSIA BUATAN (64A614)
Games and adversarial search (Chapter 5)
CS 460 Spring 2011 Lecture 4.
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
Pengantar Kecerdasan Buatan
Adversarial Search.
Game Playing in AI by: Gaurav Phapale 05 IT 6010
Alpha-Beta Search.
NIM - a two person game n objects are in one pile
9.1. Board Games and Aiming AI
Alpha-Beta Search.
Instructor: Vincent Conitzer
Alpha-Beta Search.
Minimax strategies, alpha beta pruning
Alpha-Beta Search.
CSE (c) S. Tanimoto, 2007 Search 2: AlphaBeta Pruning
ALGORITHM TYPES Divide and Conquer, Dynamic Programming, Backtracking, and Greedy. Note the general strategy from the examples. The classification is neither.
Alpha-Beta Search.
Backtracking, Search, Heuristics
Minimax strategies, alpha beta pruning
CS51A David Kauchak Spring 2019
CS51A David Kauchak Spring 2019
Backtracking, Search, Heuristics
Unit II Game Playing.
Data Structures and Algorithms
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Data Structures and Algorithms Games PLSD210

Lecture 22 - Key points Hard Problems Class P - O(nk) algorithm problems Class NP - non-deterministic polynomial Guessing step Verify solution in polynomial time Problems are believed to lie in NP Because no polynomial algorithm is known

Lecture 22 - Key points Class P or NP? Class NP problems Class P : Euler’s problem Class NP : Hamilton’s problem Class NP problems Composite numbers Assignment for m=3 Boolean satisfiability Map colouring for m=3

Travelling Salesman Problem Lecture 22 - Key points Reduction Map colouring reduces to boolean satisfiability NP-complete problems All problems in NP are reducible to them If a polynomial time algorithm for one is found then a polynomial time algorithm for all is found Travelling Salesman Problem Optimisation - but reducible to Hamiltonian Path

Lecture 22 - Key points Solving Hard Problems TSP Use heuristics -> approximate solutions TSP Start with MST, reduce with short-cuts Solution is no more than 1.5 x optimal Band solve small problems by brute force join with greedy algorithm

Games Search trees can be huge Chess: ~40 possible choices for each move 10+-move look-ahead needed to win >4010 positions to explore Modern computers just “touching” this capability Pentium @ 150MHz ~104 evaluations/second (EE student programming .. so you can add a factor of 10 if you like J ) Still a rather boring game ... ~1 year/move??

Games Board games Assume a “score” can be assigned to a position Player tries to maximise Opponent tries to minimise Game proceeds in alternating maximise and minimise steps Minimax algorithm

Minimax algorithm - Tic-Tac-Toe Board: 3 x 3 Players alternate placing a token We (programmers!) want a computer win, so Position is scored as: human_win < draw < unknown < computer_win A full board ç draw Not yet full, neither winning ç unknown

Minimax algorithm - Tic-Tac-Toe int ChooseMove( int computer, int *best_row, int *best_col ) { if ( ( val = PosValue() ) != unknown ) return val; val = computer? human_win:computer_win; for( row=0;row<3;row++) { for( col=0;col<3;col++) { if( Empty( row, col ) ) { Place( row, col, s ); rep = ChooseMove( !computer, &br, &bc ); Place( row, col, empty ); if ( (computer) && (rep>val)) || ((!computer) && (rep<val)) ) { val = rep; *best_row = row; *best_col = col; } }}} return val; }

Minimax algorithm - Tic-Tac-Toe Board: 3 x 3 First move: 549,946 recursive calls Simple minimax algorithm Checks many unnecessary checks Pruned to 18,297 with no loss by alpha-beta pruning

Minimax algorithm - Tic-Tac-Toe Move C1 ç draw Evaluate C2: Human plays: H2A ç draw So human can force draw (or do better) For computer, this is no better than C1, so evaluation of H2B and H2C is pointless refutation or cut-off, retain C1 as best move so far

Minimax algorithm - Tic-Tac-Toe When a refutation is found, this is just as good as the best move that the player could make at that point, so we proceed no further Add two parameters to ChooseMove : value that the human has to refute : value that the computer has to refute Human playing: Any move <  Computer playing: Any move >  Start with  = human_win,  = computer_win

Minimax algorithm - Tic-Tac-Toe int ChooseMove( int computer, int *best_row, int *best_col, int alpha, int beta ) { if ( ( val = PosValue() ) != unknown ) return val; val = computer? alpha:beta; for( row=0;row<3;row++) { for( col=0;col<3;col++) { if( Empty( row, col ) ) { Place( row, col, s ); rep = ChooseMove( !computer, &br, &bc ); Place( row, col, empty ); if ( (computer) && (rep>val)) || ((!computer) && (rep<val)) ) { val = rep; if ( computer ) alpha = val; else beta = val; *best_row = row; *best_col = col; if ( alpha >= beta ) return val; } }}} return val; }

 Search - Additional heuristics Move ordering Use simple heuristics to sort moves Best moves first They’re more likely to cause a cut-off! Has a dramatic effect in chess One move look-ahead Naive, material based Dramatic increase in number of cut-offs!

 Search - Additional heuristics Transposition tables Remember positions that have already been evaluated Their scores are known & can be returned immediately Large numbers of positions need to be stored Store “early” positions only Detecting a “deep” one won’t help so much How to store the positions? Need fast, efficient look-up Consider 3x3 tic-tac-toe board Then consider chess!

 Search - Additional heuristics Transposition tables How to store the positions? Need fast, efficient look-up Consider 3x3 tic-tac-toe board Then consider chess!

 Search - Additional heuristics Transposition tables Use a hash table for fast lookup Easy to generate key from arbitrary bit-string Representative data can be easily generated Fast Various collision handling strategies