CompSci 4 28.1 Recursion & Minimax Playing Against the Computer Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything,

Slides:



Advertisements
Similar presentations
Welcome Back to School!!! Mr. Sortina.
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."
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.
Game Theory, Part 1 Game theory applies to more than just games. Corporations use it to influence business decisions, and militaries use it to guide their.
AI for Connect-4 (or other 2-player games) Minds and Machines.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
1 CSC 550: Introduction to Artificial Intelligence Fall 2008 search in game playing  zero-sum games  game trees, minimax principle  alpha-beta pruning.
CS 4700: Foundations of Artificial Intelligence Bart Selman Reinforcement Learning R&N – Chapter 21 Note: in the next two parts of RL, some of the figure/section.
Chess AI’s, How do they work? Math Club 10/03/2011.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Artificial Intelligence in Game Design
This time: Outline Game playing The minimax algorithm
Game Playing CSC361 AI CSC361: Game Playing.
Contact My is The course web address is
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Adversarial Search: Game Playing Reading: Chess paper.
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.
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.
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.
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. Introduction Why is game playing so interesting from an AI point of view? –Game Playing is harder then common searching The search space.
Game Playing.
Senior Project – Computer Science – 2015 Modelling Opponents in Board Games Julian Jocque Advisor – Prof. Rieffel Abstract Modelling opponents in a game.
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.
Section 3.1: Proof Strategy Now that we have a fair amount of experience with proofs, we will start to prove more difficult theorems. Our experience so.
Mark Dunlop, Computer and Information Sciences, Strathclyde University 1 Algorithms & Complexity 5 Games Mark D Dunlop.
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.
Minimax with Alpha Beta Pruning The minimax algorithm is a way of finding an optimal move in a two player game. Alpha-beta pruning is a way of finding.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
1 Adversarial Search CS 171/271 (Chapter 6) Some text and images in these slides were drawn from Russel & Norvig’s published material.
W 2 L 1 sh 1 C lessons LessonSubjectBook Week 1 lesson 1Objects, names Week 1 lesson 2Statements, layout Week 2 lesson 1Functions, decomposition Week 2.
For Wednesday Read chapter 7, sections 1-4 Homework: –Chapter 6, exercise 1.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 What can a computer be commanded to do?
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.
Backtracking and Games Eric Roberts CS 106B January 28, 2013.
CSCI 4310 Lecture 6: Adversarial Tree Search. Book Winston Chapter 6.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW AI for games: min-max search COMP #
Today’s Topics Playing Deterministic (no Dice, etc) Games –Mini-max –  -  pruning –ML and games? 1997: Computer Chess Player (IBM’s Deep Blue) Beat Human.
Game tree search Thanks to Andrew Moore and Faheim Bacchus for slides!
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
CompSci Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the.
CPS Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the “right-hand”
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
CompSci Recursion & Minimax Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything, ace your computer science.
K 3 -Saturator By Roy Oursler. What is K 3 -Saturator K 3 -Saturator is a combinatorial game A combinatorial game is a two player game where both of the.
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
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.
CMSC201 Computer Science I for Majors Lecture 19 – Recursion (Continued) Prof. Katherine Gibson Prof. Jeremy Dixon Based on slides from UPenn’s.
Backtracking, Search, Heuristics
CMSC201 Computer Science I for Majors Lecture 20 – Recursion (Continued) Prof. Katherine Gibson Based on slides from UPenn’s CIS 110, and from previous.
Intro to Computer Science II
PENGANTAR INTELIJENSIA BUATAN (64A614)
Adversarial Search.
Game Playing.
Checkers Move Prediction Algorithms
NIM - a two person game n objects are in one pile
Last Class We Covered Recursion Stacks Parts of a recursive function:
Backtracking, Search, Heuristics
CS51A David Kauchak Spring 2019
Backtracking, Search, Heuristics
Unit II Game Playing.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

CompSci Recursion & Minimax Playing Against the Computer Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything, ace your computer science course. Otherwise, study & program something you don't understand, then see Key to Acing Computer Science

CompSci Recursion & Minimax Winning Tic-tac-toe Anticipate the implications of your move. Avoid moves which could enable your opponent to win. Attempt moves which would force your opponent to lose, so you win.

CompSci Recursion & Minimax How to pass the buck: recursion! Imagine this: You have all sorts of friends who are willing to help you do your work with two caveats: o They won't do all of your work o They will only do the type of work you have to do Example: How would you do your homework consisting of 100 calculus problems? Easy – do the first problem yourself and ask your friend to do the rest

CompSci Recursion & Minimax How could this approach work? What actually happens is that your friends doing most of your work have friends of their own. Everyone eventually does a small part of the work and piece it back together to do the work in its entirity. In the last example, 100 total people would be working on the homework, each person doing only one problem each and passing on the rest. Important: the person to do the last homework problem does it entirely without help.

CompSci Recursion & Minimax The Parts of Recursion  Base Case – this is the simplest form of the problem which can be solved directly. In the example earlier this would be doing 1 homework problem.  Recursive Step – this is when a smaller identical problem is solved as part of solving the larger problem. In the earlier example, this would be passing along all but one of the homework to a friend.

CompSci Recursion & Minimax Example: Finding the Maximum  Imagine you are given a stack of 1000 unsorted papers with grades on them and told to find the maximum grade.  You can only get help from friends in finding the maximum and in less than the 1000 papers you were given.  What do you ask your friend to do to help you find the maximum in the least effort on your part?

CompSci Recursion & Minimax Example: Sorting  Now imagine you must sort those 1000 papers by grade. Define a recursive algorithm to solve this problem. To do this define two parts:  What is the simplest number of papers to sort, and how would you sort them?  How would you divide the task in to smaller sorting tasks and integrate theses solutions to sort the entire set of N papers?

CompSci Recursion & Minimax The Problem Your Moves My Moves Your Moves My Moves..... Your Moves.....

CompSci Recursion & Minimax Example: the Minimax Algorithm  In many games, one players loss is another player's gain.  A winning strategy for this type of game is to minimize the maximum potential gain of your opponent and assume your opponent is following the same strategy.  Better than brute force lookahead:  Consider all possible moves to the bitter end  Pick the move that leads to a win, if possible  Why not program Computer Chess that way?

CompSci Recursion & Minimax Example: the Minimax Algorithm  Since your opponent is following the same strategy, and game moves eventually end the game, this algorithm can be implemented recursively. Anticipate the implications of your move. Avoid moves which could enable your opponent to win. Attempt moves which would force your opponent to lose, so you win.

CompSci Recursion & Minimax A Winning Computer Player for Tic-tac-toe  What is the algorithm? Assume the input is a board and whose turn it is (X or O): evaluate(board, position)  What is the base case? What is the simplest board to evaluate win, loss, or cat outcome? Remember you assume both players are doing everything possible to win.  What is the recursive step?

CompSci Recursion & Minimax How can we adapt this to Chess?  Can’t go to the bitter end: Takes too long: “Eons”  How can we see which move is better?  Need something like a Board Evaluation Function  What does it use to evaluate board? o Material: who has more of what kind of pieces o Position ? o Anything else?  Can then use limited look-ahead to suggest who comes out ahead o Will not be perfect o How do you avoid traps (sacrifices)?  Use Minimax based on Board Evaluation Functions