Games, page 1 CSI 4106, Winter 2005 Games Points Games and strategies A logic-based approach to games AND-OR trees/graphs Static evaluation functions Tic-Tac-Toe.

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

Adversarial Search Reference: “Artificial Intelligence: A Modern Approach, 3 rd ed” (Russell and Norvig)
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
Games & Adversarial Search
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Game Playing (Tic-Tac-Toe), ANDOR graph By Chinmaya, Hanoosh,Rajkumar.
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
Adversarial Search Chapter 6 Section 1 – 4.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Adversarial Search CSE 473 University of Washington.
MINIMAX SEARCH AND ALPHA- BETA PRUNING: PLAYER 1 VS. PLAYER 2.
10/19/2004TCSS435A Isabelle Bichindaritz1 Game and Tree Searching.
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Lecture 13 Last time: Games, minimax, alpha-beta Today: Finish off games, summary.
Artificial Intelligence in Game Design
Mahgul Gulzai Moomal Umer Rabail Hafeez
All rights reservedL. Manevitz Lecture 31 Artificial Intelligence A/O* and Minimax L. Manevitz.
This time: Outline Game playing The minimax algorithm
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.
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)
1 DCP 1172 Introduction to Artificial Intelligence Lecture notes for Chap. 6 [AIMA] Chang-Sheng Chen.
CS 460, Sessions Last time: search strategies Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Adversarial Search: Game Playing Reading: Chess paper.
Games & Adversarial Search Chapter 6 Section 1 – 4.
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 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.
CSC 412: AI Adversarial Search
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.
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.
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.
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
Game Playing.
1 Game Playing Why do AI researchers study game playing? 1.It’s a good reasoning problem, formal and nontrivial. 2.Direct comparison with humans and other.
Games CPS 170 Ron Parr. Why Study Games? Many human activities can be modeled as games –Negotiations –Bidding –TCP/IP –Military confrontations –Pursuit/Evasion.
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.
October 3, 2012Introduction to Artificial Intelligence Lecture 9: Two-Player Games 1 Iterative Deepening A* Algorithm A* has memory demands that increase.
Chapter 12 Adversarial Search. (c) 2000, 2001 SNU CSE Biointelligence Lab2 Two-Agent Games (1) Idealized Setting  The actions of the agents are interleaved.
Instructor: Vincent Conitzer
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.
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.
CSCI 4310 Lecture 6: Adversarial Tree Search. Book Winston Chapter 6.
CSE473 Winter /04/98 State-Space Search Administrative –Next topic: Planning. Reading, Chapter 7, skip 7.3 through 7.5 –Office hours/review after.
Game Playing Revision Mini-Max search Alpha-Beta pruning General concerns on games.
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.
Knowledge Search CPTR 314.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
Adversarial Search 2 (Game Playing)
Adversarial Search and Game Playing Russell and Norvig: Chapter 6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2004/home.htm Prof: Dekang.
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.
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.
Chapter 5 Adversarial Search. 5.1 Games Why Study Game Playing? Games allow us to experiment with easier versions of real-world situations Hostile agents.
Search: Games & Adversarial Search Artificial Intelligence CMSC January 28, 2003.
1 Chapter 6 Game Playing. 2 Chapter 6 Contents l Game Trees l Assumptions l Static evaluation functions l Searching game trees l Minimax l Bounded lookahead.
Adversarial Search Chapter Two-Agent Games (1) Idealized Setting – The actions of the agents are interleaved. Example – Grid-Space World – Two.
Game Playing Why do AI researchers study game playing?
Iterative Deepening A*
Introduction to Artificial Intelligence Lecture 9: Two-Player Games I
Presentation transcript:

Games, page 1 CSI 4106, Winter 2005 Games Points Games and strategies A logic-based approach to games AND-OR trees/graphs Static evaluation functions Tic-Tac-Toe Minimax Alpha-beta cutoff Extensions

Games, page 2 CSI 4106, Winter 2005 Definitions We consider non-random or semi-random games with full information, zero-sum, two-person (dual), with rational players. That's mainly board games such as chess, chequers, go -- sometimes called strategic games; some paper-and-pencil games are of this kind too.

Games, page 3 CSI 4106, Winter 2005 Definitions (2) A (pure) strategy: a complete set of advance instructions that specifies a definite choice for every conceivable situation in which the player may be required to act. In a two-player game, a strategy allows the player to have a response to every move of the opponent. Game-playing programs implement a strategy as a software mechanism that supplies the right move on request.

Games, page 4 CSI 4106, Winter 2005 A logic-based approach to games Find a winning strategy by proving that the game can be won -- use backward chaining. A very simple game: nim.  initially, there is one stack of chips;  a move: select a stack and divide it in two unequal non-empty stacks;  a player who cannot move loses the game. (The player who moves first can win.)

Games, page 5 CSI 4106, Winter Games in logic (2)

Games, page 6 CSI 4106, Winter Games in logic (3) A_wins([6], A) A_wins([5], B) A_wins([4], B) A_wins([4], A) A_wins([3], A) A_wins([3], B)A_wins([], B) A_wins([], A) The players are A and B. A_wins( P, X ) means "player X moves in position P and there is a winning continuation for A". A position is represented as a list of sizes of stacks with 3 or more chips (only those can be still divided). This is an AND/OR tree (actually a directed, acyclic AND/OR graph). Player B loses.

Games, page 7 CSI 4106, Winter Games in logic (4) A_wins([6], B) A_wins([5], A) A_wins([4], A) A_wins([4], B) A_wins([3], B) A_wins([3], A)A_wins([], A) A_wins([], B) A winning strategy would always lead to a win. Here, such a strategy is described by a subgraph with one OR edge selected from each OR node. All leaves in the subgraph must represent wins for player A. Now we cannot find a winning strategy: why?

Games, page 8 CSI 4106, Winter Games in logic (5) This kind of analysis only works for very small game trees: A_wins([8], A) A_wins([7], B) A_wins([6], A) A_wins([5], A) A_wins([4, 3], A) A_wins([4], B)

Games, page 9 CSI 4106, Winter 2005 The basic loop The basic loop in a game program: build as much of the complete tree as seems reasonable (for example, within a given time limit); evaluate the incomplete tree; prune unpromising or bad moves; make a move; get the opponent's move. Regularities: moves of player A sprout from OR nodes, moves of player B sprout from AND nodes. Seen from A's perspective, this means that A chooses one of the moves (the best move, if possible), and is ready to react to all of B's moves.

Games, page 10 CSI 4106, Winter 2005 Static evaluation A static evaluation function returns the value of a move without trying to play (which would mean simulating the rest of the game but not playing it). Usually a static evaluation function returns positive values for positions advantageous to A, negative values for positions advantageous to B. If player A is rational, he will choose the maximal value of a leaf. Player B will choose the minimal value.

Games, page 11 CSI 4106, Winter 2005 Static evaluation (2) If we can have (guess or calculate) the value of an internal node N, we can treat it as if it were a leaf. This is the basis of the minimax procedure. No tree would be necessary if we could evaluate the initial position statically. Normally we need a tree, and we need look-ahead into it. Further positions can be evaluated more precisely, because there is more information, and a more focussed search. Minimax works best for large trees, but it can be useful even in mini-games such as tic-tac-toe.

Games, page 12 CSI 4106, Winter 2005 Tic-Tac-Toe Let player A be x and let open(x), open(o) mean the number of lines open to x and o. There are 8 lines. An evaluation function for position P: f(P) = -  if o wins f(P) = +  if x wins f(P) = open(x) - open(o)otherwise Example: open(x) - open(o) = x o Assumptions: only one of symmetrical positions is generated; we build 2 levels of the game tree (one move -- one response) to have 2-ply lookahead.

Games, page 13 CSI 4106, Winter 2005 Tic-Tac-Toe (2) Player B chooses the minimal backed-up value among level 1 nodes. Player A chooses the maximal value, and makes the move. Player B, as a rational agent, selects the optimal response. x x x xxxxx xxxxx oo o o o oo x x o o o o o

Games, page 14 CSI 4106, Winter 2005 Tic-Tac-Toe (3) B's first three moves are blocking moves. Other moves lead to +  for A: the only finite value is the minimum. For A this is a three-way tie in the evaluation; the chance to get more information is to consider more plies. x xx xx o xx oo x o o x oo oo x x o x x o xx o x x o x x o x x o o o

Games, page 15 CSI 4106, Winter 2005 Tic-Tac-Toe (4) Now, what happens if B chooses a weaker move? The procedure finds a winning continuation: the best position ensures a win by forced moves. x x x x x o xx o o x o o x oo oo x o x xx o x x o x x o x x o x x o oo

Games, page 16 CSI 4106, Winter 2005 Tic-Tac-Toe (5) Building complete plies is usually not necessary. If we evaluate a position when it is generated, we may save a lot. Assume that we are at a minimizing level. If the evaluation function returns - , we do not need to consider other positions: -  will be the minimum. The same applies to +  at a maximizing level.

Games, page 17 CSI 4106, Winter 2005 Tic-Tac-Toe (6) This is possible because of the special properties of the infinite values, but we can achieve a similar effect for finite values. x x xxx xx oo o o o o x

Games, page 18 CSI 4106, Winter 2005 Tic-Tac-Toe (7) The backed-up value of the first node at level 1 is -1, so the value of the (maximizing) root must be ≥ -1. When we see = -1, we know that the value of the (minimizing) node must be ≤ -1. The whole subtree sprouting from cannot contribute anything and should not even be built. x x xxxxxoo o o o o x

Games, page 19 CSI 4106, Winter 2005 Minimax with cut-off In general, we keep a provisional value in every node. This value can only increase in an OR (maximizing) node, and decrease in an AND (minimizing) node. If an AND node with the provisional value V has a child C with a value less than V, we abandon C. If an OR node with the provisional value V has a child C with a value greater that V, we abandon C. Provisional values are established as soon as we "know something", and are propagated up the tree, from the leaves to the root.

Games, page 20 CSI 4106, Winter 2005  -  cut-off (2) i.We stop searching in and below a minimizing node N with a provisional value PV N that is less than or equal to the provisional values of its maximizing ancestors. The final value for N is PV N. ii.We stop searching in and below a maximizing node N with a provisional value PV N that is greater than or equal to the provisional values of its minimizing ancestors. The final value for N is PV N.

Games, page 21 CSI 4106, Winter 2005  -  cut-off (3) A provisional value of an OR node is called its alpha-value. A provisional value of an AND node is called its beta-value. During search, the alpha-value of a node is set to the currently largest of the final values for descendants; the beta-value of a node is set to the currently smallest of the final values for descendants. (i) is a shallow alpha-cutoff, (ii) is a shallow beta-cutoff.

Games, page 22 CSI 4106, Winter 2005  -  cut-off (4)

Games, page 23 CSI 4106, Winter 2005 Extensions, modifications "Waiting for quiescence" -- when we reach the depth limit in the middle of a dynamic exchange (large amplitude of values). Secondary search ("feedover") -- "double check" down a path that seems the best. Book moves -- "canned" continuations (openings, endgames), and forced moves. Disadvantages of minimax: relying on the optimality of the opponent's play, no spectacular sacrifices are possible (winning back beyond the search limit), the horizon effect. Queen lost Pawn lost Search limit

Games, page 24 CSI 4106, Winter 2005 What next? This is a technology for one kind of games, and quite probably not the most popular (-:). Adventure games require a very different kind of Artificial Intelligence. Visit for a nearly professional perspective. And, in general, google it.