Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit II Game Playing.

Similar presentations


Presentation on theme: "Unit II Game Playing."— Presentation transcript:

1 Unit II Game Playing

2 AND-OR GRAPHS The AND-OR GRAPH (or tree) is useful for representing the solution of problems that can solved by decomposing them into a set of smaller problems, all of which must then be solved. This decomposition, or reduction, generates arcs that we call AND arcs. One AND arc may point to any number of successor nodes, all of which must be solved in order for the arc to point to a solution. Just as in an OR graph, several arcs may emerge from a single node, indicating a variety of ways in which the original problem might be solved. This is why the structure is called not simply an AND-graph but rather an AND-OR graph (which also happens to be an AND-OR tree)

3 EXAMPLE FOR AND-OR GRAPH

4 Tic Tac Toe Rules of the Game
The game is to be played between two people (in this program between HUMAN and COMPUTER). One of the player chooses ‘O’ and the other ‘X’ to mark their respective cells. The game starts with one of the players and the game ends when one of the players has one whole row/ column/ diagonal filled with his/her respective character (‘O’ or ‘X’). If no one wins, then the game is said to be draw.

5 The game Tic Tac Toe is also known as Noughts and Crosses or Xs and Os ,the player needs to take turns marking the spaces in a 3x3 grid with their own marks, if 3 consecutive marks (Horizontal, Vertical, Diagonal) are formed then the player who owns these moves get won.

6 Assume , Player 1 - X Player 2 - O

7

8 The cells could be represent as Center square, Corner, Edge as like below

9 Number each square starts from 1 to 9 like following image

10 Consider a Board having nine elements vector. Each element will contain
0 for blank 1 indicating X player move 2 indicating O player move Computer may play as X or O player. First player is always X.

11 Algorithm Step 1:Now our board looks like   (ternary number) convert it into decimal no. The decimal no is 0. Step 2:Use the computed number i.e 0 as an index into the move table and access the vector stored in New Board Position. The new board position is   . Step 3:The vector selected in step 2 (  ) represents the way the board will look after the move that should be made. So set board equal to that vector. After complete the 3rd step your board looks like\

12

13

14 Minimax algorithm Minimax is a recursive algorithm which is used to choose an optimal move for a player assuming that the other player is also playing optimally. It is used in games such as tic-tac-toe, go, chess, isola, checkers, and many other two-player games. Such games are called games of perfect information because it is possible to see all the possible moves of a particular game. It is similar to how we think when we play a game: “if I make this move, then my opponent can only make only these moves,” and so on. Minimax is called so because it helps in minimizing the loss when the other player chooses the strategy having the maximum loss.

15 Terminology Game Tree: It is a structure in the form of a tree consisting of all the possible moves which allow you to move from a state of the game to the next state. A game can be defined a search problem with the following components: Initial state: It comprises the position of the board and showing whose move it is. Successor function: It defines what the legal moves a player can make are. Terminal state: It is the position of the board when the game gets over. Utility function: It is a function which assigns a numeric value for the outcome of a game. For instance, in chess or tic-tac-toe, the outcome is either a win, a loss, or a draw, and these can be represented by the values +1, -1, or 0, respectively.

16 How does the algorithm work?
There are two players involved in a game, called MIN and MAX. The player MAX tries to get the highest possible score and MIN tries to get the lowest possible score, i.e., MIN and MAX try to act opposite of each other.

17

18 Step 1: First, generate the entire game tree starting with the current position of the game all the way upto the terminal states. This is how the game tree looks like for the game tic-tac-toe.

19

20 Step 2: Apply the utility function to get the utility values for all the terminal states.
Step 3: Determine the utilities of the higher nodes with the help of the utilities of the terminal nodes. For instance, in the diagram below, we have the utilities for the terminal states written in the squares.

21

22

23

24 Step 4: Calculate the utility values with the help of leaves considering one layer at a time until the root of the tree. Step 5: Eventually, all the backed-up values reach to the root of the tree, i.e., the topmost point. At that point, MAX has to choose the highest value. In our example, we only have 3 layers so we immediately reached to the root but in actual games, there will be many more layers and nodes. So we have to evaluate MAX{3,2} which is 3.

25 Alpha–beta pruning  Alpha–beta pruning is a search algorithm that seeks to decrease the number of nodes that are evaluated by the minimax algorithm in its search tree. ... When applied to a standard minimax tree, it returns the same move as minimax would, but prunes away branches that cannot possibly influence the final decision.

26 The Algorithm: Let Alpha be the value of the best choice so far at any choice along the path for MAX. Let Beta be the value of the best (i.e. lowest value) so far at any choice point along the path for MIN.

27 Alpha Beta.pdf

28 Puzzle Solving 8 15 24

29 Rubik Cube

30 A self-taught artificial intelligence (AI) system called DeepCube has mastered solving the Rubik's Cube puzzle in just 44 hours without human intervention. The system's inventors have detailed their design in a paper titled 'Solving the Rubik's Cube Without Human Knowledge'.

31 Backgammon

32 RoboCup Technology Sensory System High Level Cognitive Systems
Basic Design – mechanical design, power supply Basic Control Issues – robustness, complexity

33 Robotic Soccer – application to demonstrate intelligence, robotics and vision.
Mulit Robot Sensor is provided in the system so that all players can send their own position, the position of other players, and the position of tha ball


Download ppt "Unit II Game Playing."

Similar presentations


Ads by Google