Tic tac toe simple ai game

mmkskajan 6,493 views 9 slides May 18, 2015
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

that was an Artificial intelligence logics in tic tac toi game


Slide Content

Tic Tac Toe Simple AI game K.Navaneethan ID:20058538

Introduction I chose tic-tac-toe (also known as noughts and crosses) since virtually everyone knows the game and the rules are simple enough that we don’t need an elaborate analysis of game configurations. Despite being a simple game, the basic AI principles shown here can be applied to more complicated games such as checkers, Connect 4, go and even chess.

How? So what do we mean programming AI? Basically, we would like a computer player to ‘look’ at a game board and ‘intelligently’ decide where to move. There are of course many ways to do this. In this demo I will explore a common method of searching for moves by building game trees that represent the space of possible moves (game configurations) and selecting a move which yields the best outcome.

For ‘X’, two pieces in the diagonal = 2 1 ‘X’ in second column = 1 For ‘O’, the ‘O’ in the third column = 1 e(m) = 3 – 1 = 2 This configuration is favorable to ‘X’

This will be our root node, and since it represents a configuration for which the computer needs to move it is a MAX node. The computer can move in positions 3, 5, and 6. Each of the moves yield a new configuration and are represented as children of the root node. Because the child nodes represent configurations for which the opponent must move they are MIN nodes

We need to make another set of children for each of the min nodes to achieve the desired depth of 2. Since these children are the children of MIN nodes they will be MAX nodes. This is always the case. MAX nodes have MIN children and vice-versa.

Now the root node selects the maximum value from among it’s children. The node with e (m)= 0  is the maximum so that is selected by the root node as the best move for the computer to make (moving to position 6). The algorithm predicts a loss if a move to position 3 or 5 is made where  e(m)  = -∞ for those moves.

Conclusion We will build our search tree using  Node  objects that will represent a particular move made. T here are two types of Nodes, MAX and MIN nodes. In code, we define the  MaxNode  and  MinNode   classes that will represent MAX and MIN nodes respectively. We will make use of a  class to capture the common properties and functionality of MIN and MAX nodes.

Thank you