CPS 100 9.1 Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the “right-hand”

Slides:



Advertisements
Similar presentations
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.
Advertisements

Computers playing games. One-player games Puzzle: Place 8 queens on a chess board so that no two queens attack each other (i.e. on the same row, same.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
MINIMAX SEARCH AND ALPHA- BETA PRUNING: PLAYER 1 VS. PLAYER 2.
CPS 100, Fall Backtracking by image search.
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
CompSci 100e Program Design and Analysis II March 3, 2011 Prof. Rodger CompSci 100e, Spring
CompSci Recursion & Minimax Playing Against the Computer Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything,
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
November 10, 2009Introduction to Cognitive Science Lecture 17: Game-Playing Algorithms 1 Decision Trees Many classes of problems can be formalized as search.
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)
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
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,
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
CISC 235: Topic 6 Game Trees.
Lecture 5 Note: Some slides and/or pictures are adapted from Lecture slides / Books of Dr Zafar Alvi. Text Book - Aritificial Intelligence Illuminated.
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.
Adversarial Search CS30 David Kauchak Spring 2015 Some material borrowed from : Sara Owsley Sood and others.
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.
Lecture 5: Backtracking Depth-First Search N-Queens Problem Hamiltonian Circuits.
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.
For Wednesday Read Weiss, chapter 12, section 2 Homework: –Weiss, chapter 10, exercise 36 Program 5 due.
Game Playing. Towards Intelligence? Many researchers attacked “intelligent behavior” by looking to strategy games involving deep thought. Many researchers.
Connect Four AI Robert Burns and Brett Crawford. Connect Four  A board with at least six rows and seven columns  Two players: one with red discs and.
CPS 100, Fall PFTN2Wks l Making progress on Boggle assignment  Many, many classes, each designed to do one thing  Some related by inheritance,
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.
CPS 100, Fall GridGame APT How would you solve this problem using recursion?
Game Playing. Introduction One of the earliest areas in artificial intelligence is game playing. Two-person zero-sum game. Games for which the state space.
Cilk Pousse James Process CS534. Overview Introduction to Pousse Searching Evaluation Function Move Ordering Conclusion.
CSCI 4310 Lecture 6: Adversarial Tree Search. Book Winston Chapter 6.
CPS Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze  Certain mazes can be solved using the “right-hand”
CompSci 100e 6.1 Plan for the week l More recursion examples l Backtracking  Exhaustive incremental search  When we a potential solution is invalid,
Game tree search Thanks to Andrew Moore and Faheim Bacchus for slides!
CompSci 100 Prog Design and Analysis II Oct 26, 2010 Prof. Rodger CPS 100, Fall
Backtracking & Brute Force Optimization Intro2CS – weeks
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.
CSE 143 Lecture 13 Recursive Backtracking slides created by Ethan Apter
CompSci 100e 7.1 Hashing: Log ( ) is a big number l Comparison based searches are too slow for lots of data  How many comparisons needed for a.
Adversarial Search and Game Playing Russell and Norvig: Chapter 6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2004/home.htm Prof: Dekang.
CompSci Recursion & Minimax Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything, ace your computer science.
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
CPS 100, Spring Search, Trees, Games, Backtracking l Trees help with search  Set, map: binary search tree, balanced and otherwise  Quadtree.
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.
Game playing Types of games Deterministic vs. chance
Backtracking, Search, Heuristics
BackTracking CS255.
Back Tracking.
Alpha-Beta Search.
NIM - a two person game n objects are in one pile
Alpha-Beta Search.
Alpha-Beta Search.
Minimax strategies, alpha beta pruning
Alpha-Beta Search.
Alpha-Beta Search.
Backtracking, Search, Heuristics
Minimax strategies, alpha beta pruning
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
CS51A David Kauchak Spring 2019
CS51A David Kauchak Spring 2019
Backtracking, Search, Heuristics
Unit II Game Playing.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

CPS Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the “right-hand” rule ä Other mazes, e.g., with islands, require another approach ä If you have “markers”, leave them at intersections, don’t explore the same place twice l What happens if you try to search the web, using links on pages to explore other links, using those links to … ä How many web pages are there? ä What rules to webcrawlers/webspiders follow? Who enforces the rules? l Keep track of where you’ve been don’t go there again ä Any problems with this approach?

CPS Backtracking with Boggle l Boggle tm played on 4x4 board ä Other sizes possible ä Form words by connecting letters horizontally, vertically, diagonally ä Cannot re-use letters (normally) l Two approaches ä Build words from connections, find partial words in dictionary ä Look up every word in the dictionary on the board l Which is better? How is backtracking used?

CPS Classic problem: N queens l Can queens be placed on a chess board so that no queens attack each other? ä Easily place two queens ä What about 8 queens? l Make the board NxN, this is the N queens problem ä Place one queen/column ä # different tries/column? l Backtracking ä Use “current” row in a col ä If ok, try next col ä If fail, back-up, next row

CPS Backtracking idea with N queens l Try to place a queen in each column in turn ä Try first row in column C, if ok, move onto next column ä If solved, great, otherwise try next row in column C, place queen, move onto the next column Must unplace the placed queen to keep going l What happens when we start in a column, where to start? ä If we fail, move back to previous column (which remembers where it is/failed) ä When starting in a column anew, start at beginning When backing up, try next location, not beginning l Backtracking in general, record an attempt go forward ä If going forward fails, undo the record and backup

CPS Basic ideas in backtracking search l We need to be able to enumerate all possible choices/moves ä We try these choices in order, committing to a choice ä If the choice doesn’t pan out we must undo the choice This is the backtracking step, choices must be undoable l Process is inherently recursive, so we need to know when the search finishes ä When all columns tried in N queens ä When all board locations tried in boggle ä When every possible moved tried in Tic-tac-toe or chess? Is there a difference between these games? l Summary: enumerate choices, try a choice, undo a choice, this is brute force search: try everything

CPS Computer v. Human in Games l Computers can explore a large search space of moves quickly ä How many moves possible in chess, for example? l Computers cannot explore every move (why) so must use heuristics ä Rules of thumb about position, strategy, board evaluation ä Try a move, undo it and try another, track the best move l What do humans do well in these games? What about computers? ä What about at Duke?

CPS Backtracking, minimax, game search l We’ll use tic-tac-toe to illustrate the idea, but it’s a silly game to show the power of the method ä What games might be better? Problems? l Minimax idea: two players, one maximizes score, the other minimizes score, search complete/partial game tree for best possible move ä In tic-tac-toe we can search until the end-of-the game, but this isn’t possible in general, why not? ä Use static board evaluation functions instead of searching all the way until the game ends l Minimax leads to alpha-beta search, then to other rules and heuristics

CPS Minimax for tic-tac-toe l Players alternate, one might be computer, one human (or two computer players) l Simple rules: win scores +10, loss scores –10, tie is zero ä X maximizes, O minimizes l Assume opponent plays smart ä What happens otherwise? l As game tree is explored is there redundant search? ä What can we do about this? X O X X O X X O X X X O X O X O X O X O X O X O X X O X O

CPS yfzhltea byveqye l The words above represent a simple substitution cypher ä Each letter mapped to one other letter, no inconsistencies ä Often used in cryptogram puzzles (newspaper, online, …) ä How can we write a computer program to solve this? l Ideas for solving the problem? Benchmark/ballpark idea to accept (or not) ä l Problems on the horizon?