CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Othello.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Knowledge Representation
Advertisements

Heuristic Search techniques
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."
Traveling Salesperson Problem
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)
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Game Playing Games require different search procedures. Basically they are based on generate and test philosophy. At one end, generator generates entire.
CS 484 – Artificial Intelligence
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Artificial Intelligence in Game Design
State Space 4 Chapter 4 Adversarial Games. Two Flavors Games of Perfect Information ◦Each player knows everything that can be known ◦Chess, Othello Games.
This time: Outline Game playing The minimax algorithm
1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial.
Using Search in Problem Solving
1 Game Playing Chapter 6 Additional references for the slides: Luger’s AI book (2005). Robert Wilensky’s CS188 slides:
Game Playing CSC361 AI CSC361: Game Playing.
Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour.
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)
Using Search in Problem Solving
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
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.
Minimax.
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.
KU NLP Heuristic Search Heuristic Search and Expert Systems (1) q An interesting approach to implementing heuristics is the use of confidence.
Game Playing.
AD FOR GAMES Lecture 4. M INIMAX AND A LPHA -B ETA R EDUCTION Borrows from Spring 2006 CS 440 Lecture Slides.
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.
Mark Dunlop, Computer and Information Sciences, Strathclyde University 1 Algorithms & Complexity 5 Games Mark D Dunlop.
Game Playing. Towards Intelligence? Many researchers attacked “intelligent behavior” by looking to strategy games involving deep thought. Many researchers.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
CSCI 4310 Lecture 6: Adversarial Tree Search. Book Winston Chapter 6.
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.
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.
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.
Graph Search II GAM 376 Robin Burke. Outline Homework #3 Graph search review DFS, BFS A* search Iterative beam search IA* search Search in turn-based.
Adversarial Search 2 (Game Playing)
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
Search CSC 358/ Outline Homework #6 Game search States and operators Issues Search techniques DFS, BFS Beam search A* search Alpha-beta.
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
CS 460 Spring 2011 Lecture 4.
CS Fall 2016 (Shavlik©), Lecture 11, Week 6
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
State Space 4 Chapter 4 Adversarial Games.
David Kauchak CS52 – Spring 2016
Chapter 6 : Game Search 게임 탐색 (Adversarial Search)
Minimax strategies, alpha beta pruning
Based on slides by: Rob Powers Ian Gent
State-Space Searches.
State-Space Searches.
Search.
Search.
Backtracking, Search, Heuristics
Minimax strategies, alpha beta pruning
State-Space Searches.
CS51A David Kauchak Spring 2019
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Othello

CIS 310: Visual Programming, Spring 2006 Western State College State Spaces Our next assignment will deal with state spaces. Here's the good news: * no math!

CIS 310: Visual Programming, Spring 2006 Western State College Describing Problems There are many general techniques for describing large problems. One of the simplest is the "state space". A state is just a particular configuration in your problem domain. A state space is a graph which take one configuration to another one. In general, the program will traverse through the state space toward some "goal" state. State spaces are often used when algorithmic approaches fail in a problem domain.

CIS 310: Visual Programming, Spring 2006 Western State College A State Space The state space usually comes directly from the description of the problem. The transitions may be dictated by the problem or may be chosen arbitrarily.

CIS 310: Visual Programming, Spring 2006 Western State College The Office Assignment Problem Suppose we need to decide which offices to put faculty in. The problem is that there are many different requirements: * Prof Peterson wants to be near the work room * Prof Keck wants a nice view * Prof Hite wants to be near the physics lab * Prof Cohen wants a quiet office so he can take a nap * Prof Schuster wants to be close to the xerox machine …. How might we approach this problem?

CIS 310: Visual Programming, Spring 2006 Western State College Choosing States Here's two ways to choose states: 1: Everyone is in some office 2: Some people don't have an assigned office yet Each of these implies a different state transition function. In 1, you could use an exchange function to move from state to state In 2, you could use assign someone without an office to an empty office. Which is better? I have no idea!

CIS 310: Visual Programming, Spring 2006 Western State College Evaluating States Depending on the application, there are many different ways to separate "bad" states from "good" states. Sometimes you might have a function that tells you exactly how good a state is (as in 2) Sometimes you use a function that estimates how close you are to a good state. Sometimes you just take a guess

CIS 310: Visual Programming, Spring 2006 Western State College Writing the Code In general, when you write code for a state space problem you start with a representation of the state (an object). What would the objects look like in the office example? The next part is to write a "state transition function". This takes a state object and returns a collection of "adjacent" states. (You can sometimes avoid this function by choosing the next state before constructing objects for all adjacent states …)

CIS 310: Visual Programming, Spring 2006 Western State College Algorithms If you know all the places you can go, how do you choose the best one? This is REALLY HARD! It depends a lot on the problem domain and state space structure. Note that the structure of the office assignment problem is somewhat arbitrary! The simplest algorithm is called "hill climbing" – you choose whatever state looks best and forget everything else. Loop until you decide you're done.

CIS 310: Visual Programming, Spring 2006 Western State College Search Algorithms More general algorithms don't forget old states. Rather than consider just the neighbors of the current state, other states that have been seen previously are also kept. This allows "backtracking". Consider the "maze" problem – how might you structure the state space? The search strategy? State evaluation?

CIS 310: Visual Programming, Spring 2006 Western State College Topology Issues The structure of the state space can present problems: * Multiple paths to the same state * Loops * Long paths * Too many branches Some of these need "algorithmic care" – others imply bad choices of state transition function

CIS 310: Visual Programming, Spring 2006 Western State College Heuristics A heuristic is a way of evaluating a state using a "good guess". Heuristics (rules of thumb) don't guarantee anything! But they are better than nothing. There are MANY problems where we can only guess at the answer. Note that heuristics encompass both depth first and breadth first search strategies. What's a good heuristic in the maze example? In the office assignment problem?

CIS 310: Visual Programming, Spring 2006 Western State College Games Good news: we're finally getting closer to the actual project! Consider games played against an opponent in a turn by turn manner. The states are the configurations of the game board. The transition function defines the possible moves. The evaluation function is: 1 (win), -1 (lose), or 0 (game not over). Let's look at tic-tac-toe.

CIS 310: Visual Programming, Spring 2006 Western State College Reversi Let's look in the Wikipedia: mes This will be the next project.

CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Alpha-Beta Searching

CIS 310: Visual Programming, Spring 2006 Western State College Seminar News See Dr. Violett today! Get your name on the list for Friday.

CIS 310: Visual Programming, Spring 2006 Western State College Game Trees The root of the tree is the current position The tree has some pre-determined depth, D A "static evaluator" is responsible for assigning a value between 1 (best – I win) and -1 (worst – I lose) to a game state. Basic idea: evaluate all possible moves from the current one and choose the one with the highest score.

CIS 310: Visual Programming, Spring 2006 Western State College Code myMove(Board b) moves = b.moves best move = null best score = -1 for each m in moves s = evaluate(m, false, 0) if s > best score then best score = s, best move = m pick move "best move"

CIS 310: Visual Programming, Spring 2006 Western State College A Dirty Trick Instead of having separate minimizing and maximizing levels, you can simply always maximize but return the negative of the max. I don't recommend this since you can't really tell what's going on when debugging.

CIS 310: Visual Programming, Spring 2006 Western State College Evaluation evaluate(board b, bool myMove, int depth) if (depth = max depth) return staticEval(b) r = if myMove then -1 else 1 for each m1 in b.moves() r1 = evaluate(m1, !myMove, depth+1) if myMove then r = max(r, r1) else r = min(r,r1) return r

CIS 310: Visual Programming, Spring 2006 Western State College Alpha Beta Searching Min-Max is OK but it wastes a lot of time evaluating moves that are not "good ideas". In chess, you don't need to evaluate the consequences of a stupid move, such as giving away a piece for no return. Let's look at how "stupid moves" can be found

CIS 310: Visual Programming, Spring 2006 Western State College A Game Tree Start Move M1Move M2 Counter Move M3 Counter Move M4 Counter Move M5 Counter Move M6 Max Min or better -0.5 or worse

CIS 310: Visual Programming, Spring 2006 Western State College Alpha-Beta Pruning There's a good treatment of this in the wikipedia. beta_pruning The idea is that alpha and beta describe "stupidity thresholds". When these cross you know that nobody cares about the answer in this part of tree so you can give up.

CIS 310: Visual Programming, Spring 2006 Western State College Making Alpha-Beta Effective How can you use this algorithm to eliminate as much of the game tree as possible? Make sure that you look at the best moves first – that is, tighten alpha and beta as early as possible. How? Use the static evaluator to guide the order of move evaluation.

CIS 310: Visual Programming, Spring 2006 Western State College Work Time Let's spend some time looking at your programs. Remember that the prototype is due tomorrow!