1 / 17

Unit 2 Adversarial Search

Explore different versions of Tic Tac Toe, analyze optimal moves using the MiniMax algorithm, and understand the complexities of game playing from an AI perspective.

mcarr
Download Presentation

Unit 2 Adversarial Search

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unit 2Adversarial Search AKA – Game Playing

  2. HW #1 • Handed back and grades were posted last week. • Pay attention to the details of the assignment • Revisions: • Wednesday by the start of class. • Code only.

  3. Competency Demo #1 • I'm Sorry but I don't have it graded yet. • Wednesday. I promise. • Retake: • Friday, October 4, 8:00 AM in this room. • If you can't make this due to work or another class you should provide documentation and we can schedule an alternate time.

  4. Adversarial Search

  5. Regular Tic Tac Toe • Play a few games. • What is the expected outcome • What kinds of moves “guarantee” that?

  6. Tic Tac Toe, version 2 • Modified rules • When it is your turn you can place either an X or an O. • No one owns a particular piece • The winner is the person who can get three in a row of the same type.

  7. Tic Tac TJ • Modified rules • When it is your turn you can place 1, 2, or 3 pieces as long as they all exist in a single row or column. • The winner is the person who places the LAST piece.

  8. Introduction • Why is game playing so interesting from an AI point of view? • Game Playing is harder then common searching • The search space is too large for complete searches • We are facing an unpredictable opponent • Games are adversarial search problems • Solution is strategy, contingency plan. • There are time limits • Game playing is considered to be an intelligent activity.

  9. Introduction • Two-Person games • How do we think when we play e.g. Chess? • If I move my queen there, then my opponent has to move his knight there and then can I move my pawn there and check mate. • We are making some assumptions • We want our best move • The opponent wants his best move • The opponent has the same information as we • Our opponent wants to win

  10. A simple introductory game • Consider a game where • A and B both pick their choice simultaneously • A either receives money from B (positive numbers) • or gives money to B (negative numbers) If you are A, which choice should you make? If you are B, which choice should you make?

  11. MiniMax • Games with two players MIN and MAX are a search problem with: • Initial state • Successor function • Terminal test / state • Utility function (objective / payoff)

  12. MiniMax • Utility function • Is assumed to be in relation with Max • What is good for max is always bad for min. • E.g. if max wins then min lose • In chess the utility function might be. • -1 if min wins • 0 for a draw • 1 if max wins • In other games, e.g. Othello the utility function might be more advanced. • utility = number of my pieces – number of his pieces

  13. MiniMax • Simple Games • If we play e.g. TicTacToe or NIM, we can generate a complete search tree • Some leafs in the tree will end up with max winning and some with min winning • For more complex games a complete search tree is impossible. But that’s a question for the near future.

  14. MiniMax

  15. MiniMax function MiniMax(State s, Event e, booleanisMax) { State s1 = updateState(s, e); if (isLeaf(s1)) return eval(s1); if (isMax) { int highest = SIGNIFICANTLY_LOW_NUMBER; foreach (Event e1 in maxmoves(s1)) { inttmp = MiniMax(s1, e1, !isMax); if (tmp > highest) highest = tmp; } return highest; } else { int lowest = SIGNIFICANTLY_HIGH_NUMBER; foreach (Event e1 in minmoves(s1)) { inttmp = MiniMax(s1, e1, !isMax); if (tmp < lowest) lowest = tmp; } return lowest; }

  16. MiniMax • Searching with minimax • We use depth first search to reach down to the leafs first • When we reach a leaf, we evaluate the current state by a utility function and then returns the result to the parent node. • If we are not in a leaf and have evaluated all children. • If it, from this state, is max move, then return the highest utility • If it is a min move return the lowest utility.

  17. MiniMax • Example of MiniMax – 1st version of NIM • The rules of NIM are as follows • We start with a number of sticks in a group • On each move, a player must divide a group into two smaller groups • Groups of one or two sticks can’t be divided • The last player to make a legal move wins

More Related