Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPSC 322 Introduction to Artificial Intelligence October 22, 2004.

Similar presentations


Presentation on theme: "CPSC 322 Introduction to Artificial Intelligence October 22, 2004."— Presentation transcript:

1

2 CPSC 322 Introduction to Artificial Intelligence October 22, 2004

3 Things... Office hours today from 3:30 to 4:30 pm Bring me your first midterms before the second midterm if you want to be retested on problem 3 asgn3 will be posted this evening Jessica Hodgins talk, Thursday, October 28, 1-2pm, MacLeod 214

4 Helpful CILOG stuff Counting elements in a list /* This works in Prolog, but not in CILOG */ length([H|T],N) 0 & N1 is N-1 & length(T,N1). length([],0). /* This works in CILOG */ length([H|T],X,Y) <- X1 is X+1 & length(T,X1,Y). length([],X,X). cilog: ask length([a,b,c],0,X). Answer: length([a, b, c], 0, 3).

5 Helpful CILOG stuff Sorting numeric elements in a list using insertion sort insert(X,[],[X]). insert(X,[Y|Ys],[X,Y|Ys]) <- X =< Y. insert(X,[Y|Ys],[Y|Zs]) Y & insert(X,Ys,Zs). sort([],[]). sort([X|Xu],Ys) <- sort(Xu,Zs) & insert(X,Zs,Ys).

6 The Joy of Hex The game of hexapawn 3 x 3 board 3 pawns on each side movement of pawns: white moves first pawn can move straight ahead one space if that space is empty pawn can move diagonally one space forward to capture opponent’s pawn occupying that space

7 The Joy of Hex The game of hexapawn 3 ways to win: capture all your opponent’s pawns one of your pawns reaches the opposite end of the board it’s your opponent’s turn but your opponent can’t move

8 Two Questions Second, how do you know which move to make? Use heuristic knowledge, of course! In this case, we apply this very crude board evaluation function: if you have won then board value = +10 else if opponent has won then board value = -10 else board value = number of your pawns - number of opponent’s pawns The board evaluation function is applied like this....

9 W W W - - - B B B opponent’s - W W move --> W - - B B B your --> - W W - W W - W W responses B - - W B - W - B B - B B - B B B - opp’s moves --> - - W - - W - W - - W - - W - - W W - - W - - W W - - B W - B - W W W - W B W - - B W W B W - W B - B B - B B - B B - B B - B B W - B B - B B -

10 W W W - - - B B B opponent’s - W W move --> W - - B B B your --> - W W - W W - W W responses B - - W B - W - B B - B B - B B B - opp’s moves --> - - W - - W - W - - W - - W - - W W - - W - - W W - - B W - B - W W W - W B W - - B W W B W - W B - B B - B B - B B - B B - B B W - B B - B B - 0 1 1 -1 -10 -10 0 -1

11 W W W - - - B B B opponent’s - W W move --> W - - B B B your --> - W W - W W - W W responses B - - 0 W B - -10 W - B -10 B - B B - B B B - opp’s moves --> - - W - - W - W - - W - - W - - W W - - W - - W W - - B W - B - W W W - W B W - - B W W B W - W B - B B - B B - B B - B B - B B W - B B - B B - 0 1 1 -1 -10 -10 0 -1

12 W W W - - - B B B opponent’s - W W move --> W - - 0 B B B your --> - W W - W W - W W responses B - - 0 W B - -10 W - B -10 B - B B - B B B - opp’s moves --> - - W - - W - W - - W - - W - - W W - - W - - W W - - B W - B - W W W - W B W - - B W W B W - W B - B B - B B - B B - B B - B B W - B B - B B - 0 1 1 -1 -10 -10 0 -1

13 W W W - - - B B B opponent’s - W W move --> W - - 0 B B B your --> - W W response B - - 0 B - B opp’s moves --> - - W - - W - W - W - - B W - B - W B - B B - B B - B 0 1 1

14 What if white makes an unexpected move?

15 W W W - - - B B B opponent’s - W W move --> W - - 0 B B B your --> - W W response B - - 0 B - B opp’s move --> - - W W - - B - B 0 not this...

16 W W W - - - B B B opponent’s - W W move --> W - - 0 B B B your --> - W W response B - - 0 B - B opp’s move --> - - W B W - B - B 1...but this

17 What if white makes a different move? Apply this search technique again to white’s move and make your next move accordingly

18 your - W W move --> B - - B - B opponent’s - - W move --> B W - B - B

19 your - W W move --> B - - B - B opponent’s - - W move --> B W - B - B your B - W - - W - - W - - W responses -> - W - B B - B B - B W B B - B - - B B - - B - - opponent’s - - - - - - - - - - - - - - W - - W moves --> B W - B B W B W - B B W B - B B - B - - B - - B B - - B - - W - - B W -

20 your - W W move --> B - - B - B opponent’s - - W move --> B W - B - B your B - W - - W - - W - - W responses -> - W - B B - B B - B W B B - B - - B B - - B - - 10 opponent’s - - - - - - - - - - - - - - W - - W moves --> B W - B B W B W - B B W B - B B - B - - B - - B B - - B - - W - - B W - 1 2 1 2 -10 -10

21 your - W W move --> B - - B - B opponent’s - - W move --> B W - B - B your B - W - - W - - W - - W responses -> - W - B B - 1 B B - 1 B W B -10 B - B - - B B - - B - - 10 opponent’s - - - - - - - - - - - - - - W - - W moves --> B W - B B W B W - B B W B - B B - B - - B - - B B - - B - - W - - B W - 1 2 1 2 -10 -10

22 your - W W move --> B - - B - B opponent’s - - W move --> B W - 10 B - B your B - W - - W - - W - - W responses -> - W - B B - 1 B B - 1 B W B -10 B - B - - B B - - B - - 10 opponent’s - - - - - - - - - - - - - - W - - W moves --> B W - B B W B W - B B W B - B B - B - - B - - B B - - B - - W - - B W - 1 2 1 2 -10 -10

23 your - W W move --> B - - B - B opponent’s - - W move --> B W - 10 B - B your B - W response -> - W - B - B 10

24 What if...?...way back at the beginning there was an obvious win for you in your search space?

25 W W W - - - B B B opponent’s - W W move --> W - - B B B your --> - W W - W W - W W responses B - - W B - W - B B - B B - B B B - opp’s moves --> - - W - - W - W - - W - - W - - W W - - W - - W W - - B W - B - W W W - W B W - - B W W B W - W B - B B - B B - B B - B B - B B W - B B - B B - 0 1 1 -1 -10 -10 +10 -1

26 W W W - - - B B B opponent’s - W W move --> W - - B B B should you move here? your --> - W W - W W - W W responses B - - W B - W - B B - B B - B B B - opp’s moves --> - - W - - W - W - - W - - W - - W W - - W - - W W - - B W - B - W W W - W B W - - B W W B W - W B - B B - B B - B B - B B - B B W - B B - B B - 0 1 1 -1 -10 -10 +10 -1

27 W W W - - - B B B opponent’s - W W move --> W - - B B B NOOOOO!!!! your --> - W W - W W - W W responses B - - W B - W - B B - B B - B B B - opp’s moves --> - - W - - W - W - - W - - W - - W W - - W - - W W - - B W - B - W W W - W B W - - B W W B W - W B - B B - B B - B B - B B - B B W - B B - B B - 0 1 1 -1 -10 -10 +10 -1

28 Game search (also known as adversarial search) has these components: move (or board) generator static board evaluation function (this is the heuristic part - it doesn’t generate moves or look ahead - it’s static) minimax algorithm to alternately propagate minima and maxima upward from “bottom”

29 Minimax algorithm Start with the following: a) there are two players, MAX and MIN b) it’s MAX’s turn to move c) MAX has a static board evaluation function that returns bigger values if a board is favorable to MAX d) the evaluation function gets better as the game gets closer to a goal state (else why bother to generate the game space?) e) MAX believes that MIN’s evaluation function is no better than MAX’s (if that’s not true, then MAX should at least avoid betting money on this game)

30 Minimax algorithm 1.Generate the game tree to as many levels (plies) that time and space constraints allow. The top level is called MAX (as in it’s now MAX’s turn to move), the next level is called MIN, the next level is MAX, and so on. 2.Apply the evaluation function to all the terminal (leaf) states/boards to get “goodness” values 3.Use those terminal board values to determine the values to be assigned to the immediate parents: a) if the parent is at a MIN level, then the value is the minimum of the values of its children b) if the parent is at a MAX level, then the value is the maximum of the values of its children 4.Keep propagating values upward as in step 3 5.When the values reach the top of the game tree, MAX chooses the move indicated by the highest value

31 Minimax algorithm 1.Generate the game tree to as many levels (plies) that time and space constraints allow. The top level is called MAX (as in it’s now MAX’s turn to move), the next level is called MIN, the next level is MAX, and so on. 2.Apply the evaluation function to all the terminal (leaf) states/boards to get “goodness” values 3.Use those terminal board values to determine the values to be assigned to the immediate parents: a) if the parent is at a MIN level, then the value is the minimum of the values of its children b) if the parent is at a MAX level, then the value is the maximum of the values of its children 4.Keep propagating values upward as in step 3 5.When the values reach the top of the game tree, MAX chooses the move indicated by the highest value

32 Minimax algorithm MAX (it’s MAX’s turn to move)

33 Minimax algorithm MAX (it’s MAX’s turn to move) MIN

34 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX

35 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN

36 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX

37 Minimax algorithm 1.Generate the game tree to as many levels (plies) that time and space constraints allow. The top level is called MAX (as in it’s now MAX’s turn to move), the next level is called MIN, the next level is MAX, and so on. 2.Apply the evaluation function to all the terminal (leaf) states/boards to get “goodness” values 3.Use those terminal board values to determine the values to be assigned to the immediate parents: a) if the parent is at a MIN level, then the value is the minimum of the values of its children b) if the parent is at a MAX level, then the value is the maximum of the values of its children 4.Keep propagating values upward as in step 3 5.When the values reach the top of the game tree, MAX chooses the move indicated by the highest value

38 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX

39 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8

40 Minimax algorithm 1.Generate the game tree to as many levels (plies) that time and space constraints allow. The top level is called MAX (as in it’s now MAX’s turn to move), the next level is called MIN, the next level is MAX, and so on. 2.Apply the evaluation function to all the terminal (leaf) states/boards to get “goodness” values 3.Use those terminal board values to determine the values to be assigned to the immediate parents: a) if the parent is at a MIN level, then the value is the minimum of the values of its children b) if the parent is at a MAX level, then the value is the maximum of the values of its children 4.Keep propagating values upward as in step 3 5.When the values reach the top of the game tree, MAX chooses the move indicated by the highest value

41 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8

42 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8 5 -3 8 -12 7 -42 13 -10 -8

43 Minimax algorithm 1.Generate the game tree to as many levels (plies) that time and space constraints allow. The top level is called MAX (as in it’s now MAX’s turn to move), the next level is called MIN, the next level is MAX, and so on. 2.Apply the evaluation function to all the terminal (leaf) states/boards to get “goodness” values 3.Use those terminal board values to determine the values to be assigned to the immediate parents: a) if the parent is at a MIN level, then the value is the minimum of the values of its children b) if the parent is at a MAX level, then the value is the maximum of the values of its children 4.Keep propagating values upward as in step 3 5.When the values reach the top of the game tree, MAX chooses the move indicated by the highest value

44 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8 5 -3 8 -12 7 -42 13 -10 -8

45 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8 5 -3 8 -12 7 -42 13 -10 -8 5 8 7 13 -8

46 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8 5 -3 8 -12 7 -42 13 -10 -8 5 8 7 13 -8 5 7 -8

47 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8 5 -3 8 -12 7 -42 13 -10 -8 5 8 7 13 -8 5 7 -8 7

48 Minimax algorithm 1.Generate the game tree to as many levels (plies) that time and space constraints allow. The top level is called MAX (as in it’s now MAX’s turn to move), the next level is called MIN, the next level is MAX, and so on. 2.Apply the evaluation function to all the terminal (leaf) states/boards to get “goodness” values 3.Use those terminal board values to determine the values to be assigned to the immediate parents: a) if the parent is at a MIN level, then the value is the minimum of the values of its children b) if the parent is at a MAX level, then the value is the maximum of the values of its children 4.Keep propagating values upward as in step 3 5.When the values reach the top of the game tree, MAX chooses the move indicated by the highest value

49 Minimax algorithm MAX (it’s MAX’s turn to move) MIN MAX MIN MAX 5 -3 17 9 8 22 -12 4 7 -42 -9 13 36 -10 -6 -8 5 -3 8 -12 7 -42 13 -10 -8 5 8 7 13 -8 5 7 -8 7

50 Minimax algorithm MAX (it’s MAX’s turn to move) MIN 7 7

51 Minimax algorithm A simple but powerful technique......how powerful is it?

52 Deep Blue vital statistics: 200,000,000 moves per second 480 custom chess-playing chips 1997

53

54 Deep Blue Garry Kasparov vital statistics: 200,000,000 moves per second 3 moves per second 480 custom chess-playing chips meat 1997

55

56 Deep Blue defeats Garry Kasparov 3.5 games to 2.5 games Kasparov wins $400,000 Deep Blue wins $700,000 The human race is humiliated 1997

57 2003 Garry Kasparov takes on Deep Junior

58 Deep Junior and Garry Kasparov tie 3 games each Kasparov wins $500,000 just for being there Deep Junior and Kasparov split another $500,000 Honor of human race is restored 2003

59 Deep Junior and Garry Kasparov tie 3 games each Kasparov wins $500,000 just for being there Deep Junior and Kasparov split another $500,000 Honor of human race is restored...or is it? 2003

60 Computer chess rankings have increased about 200 points every 5 years, due in large part to increases in CPU speed

61 Deep Blue Deep Junior vital statistics: 200,000,000 moves per second 3,000,000 moves per second 480 custom chess-playing chips 8 1.6 GHz Intel processors But speed doesn’t explain Deep Junior

62

63 Deep Junior 8 Chess Playing Software by ChessBase Two Exclusive Bonuses!!Deep Junior 8 - Tips, ToolsTwo Exclusive Bonuses!!Deep Junior 8 - Tips, Tools and Tactics plus Chess Masterpiecesand Tactics plus Chess Masterpieces Deep Junior 8 with Two Chess Engines!! * Fritz 8 User Interface * Complete Training Functions * Tournament Book * HUGE Database * 3D Boards * Free Access to Playchess.com Special Pricing $79.95 (US) Deep Junior 8 - Double World Champion! This chess program, written by the Israelis Amir Ban and Shay Bushinsky, has achieved everything it could wish for. Junior won the Computer Chess World Championship in 2001 and 2002, and it can look back on a string of successes against human beings in tournaments and matches. Unforgettable was its performance against Garry Kasparov in the "Man vs Machine" match in New York in January 2003. With millions of people following on the Internet, double world champion Junior played exciting, imaginative chess to hold the world’s strongest player to a 3:3 draw. Deep Junior 8 - You've Got to Love it! You're going to love Junior 8 and its tremendous attacking style. Junior 8 shows a new quality of computer chess. It has a deep understanding of initiative and attacking chances and likes to sacrifice material more than any other existing chess program. Many of the world's strongest players already use Junior as their analytical partner. It is considered one of the most reliable tactical programs around. Junior’s unique style is very human-like in often preferring positional advantages to material. from www.chesscentral.com

64

65

66

67

68


Download ppt "CPSC 322 Introduction to Artificial Intelligence October 22, 2004."

Similar presentations


Ads by Google