Tic-Tac-Toe - non-AI and AI Technique-Slide Handouts
Tic-Tac-Toe - non-AI and AI Technique-Slide Handouts
O
Winning position of P2
O
X
Winning position of P1
X
X
How to play tic-tac-toe using
Computer ?
• Either P1 or P2 will be played by computer
• Computer can use two Techniques to play this
game by
– Non-AI technique
– AI technique
Representation of board position in
computer memory
0 1 2
1. Using 3x 3 Matrix 3 4 5
6 7 8
0 1 2 3 4 5 6 7 8
Non-AI technique
O O
• Using rules X
Vector representation
2 0 0 0 1 0 0 0 0
Non-AI technique
• System will prepare a rule base of 3^ 9 rules
like O O
X
index = 2 x38 + 0 x37 + 0 x36 + 0 x35 + 1x34 + 0 x33 + 0 x32 + 0 x31 + 0 x30
= 2 x38 + 1x34 = 2 x6561 + 1x81 = 13203 < 39 = 19683
Non-AI technique
• How to use index?
Index Vector V
1 [000,000,000]
3^9 […………………..]
Tic-Tac-Toe game tree
O O
………....
OO
O O X O
X
X ………....
Tic-Tac-Toe AI technique
2 1 0 1 0 1 0 2 0
4 X 9 element matrix
2 1 2 1 0 1 0 2 0
2 1 0 1 2 1 0 2 0
2 1 0 1 0 1 2 2 0
2 1 0 1 0 1 0 2 2
Find all possible moves from the given state and choose
best one if it is turn of player X
X O
O O
X
• 50,3, 3,3
Find all possible moves from the given state and
choose best one if it is turn of player O
X O
O X O