Upcoming SlideShare
×

Game Tree ( Oyun Ağaçları )

4,751 views

Published on

How computer(Artificial Intelligence) choose next move. How to apply Minimax Method and Alpha & Beta Pruning step by step.

Published in: Technology
5 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

Views
Total views
4,751
On SlideShare
0
From Embeds
0
Number of Embeds
767
Actions
Shares
0
185
0
Likes
5
Embeds 0
No embeds

No notes for slide

Game Tree ( Oyun Ağaçları )

1. 1. Unbeatable TicTacToe (xox) Alp Çoker www.alpcoker.com [email_address] Game Tree
2. 2. <ul><li>Game playing was one of the first tasks undertaken in AI as soon as computers became programmable. </li></ul>
3. 3. Game Systems Rely On <ul><ul><li>Search techniques </li></ul></ul><ul><ul><li>Heuristic functions </li></ul></ul><ul><ul><li>Bounding and pruning techn i qiues </li></ul></ul><ul><ul><li>Knowledge database on game </li></ul></ul>
4. 4. Board Games Tic Tac Toe,Chess,Go....
5. 5. Why Board Games? <ul><li>T wo opponents . </li></ul><ul><li>Game states are easy to represent. </li></ul><ul><li>N ot involving chance or hidden . </li></ul><ul><li>Search concentrate on one player. </li></ul>
6. 6. Minimax Method <ul><li>Try to find next best move in a game with 2 player . </li></ul><ul><li>The object of a search is to find a path from the starting position to a goal position </li></ul><ul><li>It calculates all possible game states by examining all opposing moves . </li></ul><ul><li>Determine the next move against best play[opponent] . </li></ul>
7. 7. Minimax Method <ul><li>Max tries to maximize its score </li></ul><ul><li>Min tries to minimize Max’s score (Min) </li></ul><ul><li>Goal: </li></ul><ul><li>Move to position of highest minimax value </li></ul>
8. 8. Minimax Method <ul><li>Minimize M aximum L oss </li></ul><ul><li>OR </li></ul><ul><li>M aximize M inimum G ain </li></ul>
9. 9. Minimax Search Algorithm <ul><li>1. Generate the whole game tree to leaves </li></ul><ul><li>2. Apply utility (payoff) function to leaves </li></ul><ul><li>3. Back-up values from leaves toward the root: </li></ul><ul><li>* a Max node computes the max of its child values </li></ul><ul><li>* a Min node computes the Min of its child values </li></ul><ul><li>4. When value reaches the root: choose max </li></ul><ul><li>value and the corresponding move. </li></ul>
10. 10. Evaluation Function <ul><li>Each game outcome has a payoff, which we can represent as a number </li></ul><ul><li>By convention, we prefer positive numbers </li></ul><ul><li>In some games, the outcome is either a simple win ( +1 ) or a simple loss ( -1 ) </li></ul><ul><li>In some games, you might also tie, or draw ( 0 ) </li></ul>
11. 11. Minimax ( Generate Tree )
12. 12. Minimax ( Decide Whose Turn ) MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
13. 13. Minimax ( Evaluate Funcions ) 12 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
14. 14. Minimax ( Evaluate Funcions ) 12 7 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
15. 15. Minimax ( Evaluate Funcions ) 12 12 7 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
16. 16. Minimax ( Evaluate Funcions ) 12 4 12 7 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
17. 17. Minimax ( Evaluate Funcions ) 4 12 4 12 7 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
18. 18. Minimax ( Evaluate Funcions ) 4 3 12 7 6 3 4 18 6 15 7 24 15 12 5 18 6 7 11 7 24 1 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
19. 19. Minimax ( Evaluate Funcions ) 7 4 3 12 7 6 3 4 18 6 15 7 24 15 12 5 18 6 7 11 7 24 1 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN
20. 20. Minimax ( Evaluate Funcions ) 4 3 12 6 3 4 18 6 15 24 15 12 5 18 6 11 7 24 1 MAX ( Artificial Intelligence ) MIN ( Player ) MAX MIN 7 7 7 7
21. 21. α-β Pruning <ul><li>Extension of Minimax Algorithm. </li></ul><ul><li>With the help of α-β Pruning we can reduce the size of game tree so we can get quicker response . </li></ul>
22. 22. α-β Pruning <ul><ul><li>If a move is determined worse than another move already examined, then there is no need for further examination of the node. </li></ul></ul>
23. 23. α-β Pruning 11 7 5 1 8 10 16 14 2 MAX ( Artificial Intelligence ) MIN ( Player ) MAX
24. 24. α-β Pruning 7 11 7 5 1 8 10 16 14 2 <7 MAX ( Artificial Intelligence ) MIN ( Player ) MAX
25. 25. α-β Pruning 7 11 7 5 1 8 10 16 14 2 <7 >7 MAX ( Artificial Intelligence ) MIN ( Player ) MAX
26. 26. α-β Pruning 7 11 7 5 1 8 10 16 14 2 <7 >7 <5 MAX ( Artificial Intelligence ) MIN ( Player ) MAX
27. 27. α-β Pruning 7 11 5 7 5 8 10 16 2 <7 >7 <5 In 7<x and 5>x interval there can be no x , so we don’t Need to traverse in nodes 14 and 1 1 14 MAX ( Artificial Intelligence ) MIN ( Player ) MAX
28. 28. α-β Pruning 7 11 7 5 8 MAX ( Artificial Intelligence ) MIN ( Player ) MAX 10 16 2 <7 >7 <5 1 14 <10 In 7<x and 10>x interval there can be x then continue in nodes 2 and 8
29. 29. α-β Pruning 7 11 7 5 8 MAX ( Artificial Intelligence ) MIN ( Player ) MAX 10 16 2 <7 >7 <5 1 14 <2 In 7<x and 2>x interval there can be no x , so we don’t Need to traverse in node 8.
30. 30. α-β Pruning 7 7 11 7 5 8 MAX ( Artificial Intelligence ) MIN ( Player ) MAX 10 16 2 <7 >7 <5 1 14 <2
31. 31. Tic Tac Toe
32. 32. Tic Tac Toe Game Search
33. 33. Applying Minimax & α-β Pruning <ul><li>Evaluation function of Tic Tac Toe game is just win , lose and draw. </li></ul><ul><li>Computer traverse all nodes until leaf then give every leaf evaluation value. By using minimax method computer select best move. </li></ul><ul><li>Win by Computer : 1 </li></ul><ul><li>Win by Opponent : -1 </li></ul><ul><li>Draw : 0 </li></ul>
34. 34. Applying Minimax & α-β Pruning I assume the game state is like above form. Next move will be X and that will be determined by computer using Minimax Method with α-β Pruning step by step.
35. 35. -1 0 0 -1 +1 +1 0 0 MAX ( AI ) MAX ( AI ) MIN ( Opponent ) +1 +1 MIN ( Opponent ) -1 -1 0 0 α-β Pruning Computer Choses That Move
36. 36. ¿ Questions ?
37. 37. Alp Çoker www.alpcoker.com [email_address] Thanks...