games search constraint satisfactionrickl/courses/cs-171/0-ihler-2016... · game search: exercise 1...

35
Games Search & Constraint Satisfaction Thur, July 14, 2016

Upload: others

Post on 22-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Games Search &

Constraint Satisfaction

Thur, July 14, 2016

Page 2: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Game Search: Exercise 1

In the game tree below it is MAX's turn to move. At each leaf node is the estimated score of that resulting position as returned by the heuristic static evaluator.

Fill in the values of node A-L.

6

A B 2

D E F G H I 7C

MAX

MIN

MAX

5 3 J 8 2 6 7 1 9 3 3 K 1 4 3 6 4 L

Page 3: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Game Search: Exercise 1

In the game tree below it is MAX's turn to move. At each leaf node is the estimated score of that resulting position as returned by the heuristic static evaluator.

Fill in the values of node A-L.

6

A 3 2

8 7 9 3 H 4 7C

MAX

MIN

MAX

5 3 J 8 2 6 7 1 9 3 3 K 1 4 3 6 4 L

First, fill in the subtrees with the leaf nodes known.

Page 4: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Game Search: Exercise 1

In the game tree below it is MAX's turn to move. At each leaf node is the estimated score of that resulting position as returned by the heuristic static evaluator.

Fill in the values of node A-L.

6

6 3 2

8 7 9 3 H 4 7C

MAX

MIN

MAX

5 3 J 8 2 6 7 1 9 3 3 K 1 4 3 6 4 L

Then fill in the values from the top.

Page 5: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Game Search: Exercise 1

In the game tree below it is MAX's turn to move. At each leaf node is the estimated score of that resulting position as returned by the heuristic static evaluator.

Fill in the values of node A-L.

6

6 3 2

8 7 9 3 2 4 76

MAX

MIN

MAX

5 3 J 8 2 6 7 1 9 3 3 K 1 4 3 6 4 L

Work all the way to the bottom.

Page 6: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Game Search: Exercise 1

In the game tree below it is MAX's turn to move. At each leaf node is the estimated score of that resulting position as returned by the heuristic static evaluator.

Fill in the values of node A-L.

6

6 3 2

8 7 9 3 2 4 76

MAX

MIN

MAX

5 3 6 8 2 6 7 1 9 3 3 2 1 4 3 6 4 7

Work all the way to the bottom.

Page 7: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Game Search: Exercise 2

Infer the range constraints on nodes A-E.

6

6 3 2

8 7 9 3 2 4 A6

MAX

MIN

MAX

5 3 6 8 B 6 7 1 9 3 3 2 1 4 3 C D E

Page 8: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Game Search: Exercise 2

Infer the range constraints on nodes A-E.

6

6 3 2

8 7 9 3 2 4 A6

MAX

MIN

MAX

5 3 6 8 B 6 7 1 9 3 3 2 1 4 3 C D E

A ≥ 2B ≤ 8One of C, D, E ≥ 2 (C, D, E cannot be all < 2)

Page 9: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Heuristic Evaluation Functions: ExerciseYOU and FRIEND are driving a car from S and notice a rare Pokemon at G. You decide to play a turn based game to decide who should catch it. The rules are:

1. YOU move first, then players (YOU and FRIEND) alternate moves. Making a move is required;

2. On their turn, a player chooses to drive the car to any allowed stops. The other player rides the car;

3. Allowed stops are the stops that are adjacent to the current stop, and are in front. You may not travel back;

4. Whoever gets G on their turns wins.

What could be a reasonable heuristic evaluation function?

S

A

B

D

E

CH

F

G

Travel Direction

Page 10: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Heuristic Evaluation Functions: ExerciseAssume we use the heuristic evaluation function:

E(n) = Y(n) - F(n) Y(n) is the total of YOUR winning pathF(n) is the total of FRIEND winning path

S

A

B

D

E

CH

F

G

Travel Direction

Page 11: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Heuristic Evaluation Functions: ExerciseAssume we use the heuristic evaluation function:

E(n) = Y(n) - F(n) Y(n) is the total of YOUR winning pathF(n) is the total of FRIEND winning path

Observation:

On YOU turn: If path length from current node to G is even, FRIEND wins. If path length from current node to G is odd, YOU win.

S

A

B

D

E

CH

F

G

Travel Direction

Page 12: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Heuristic Evaluation Functions: ExerciseAssume we use the heuristic evaluation function:

E(n) = Y(n) - F(n) Y(n) is the total of YOUR winning pathF(n) is the total of FRIEND winning path

Observation

On YOU turn: If path length from current node to G is even, FRIEND wins. If path length from current node to G is odd, YOU win.

S

A

B

D

E

CH

F

G

Travel Direction

E(nY,n) = OddPath(nY, n, G) - EvenPath(nY, n, G)

nY is the current node on YOU turn, n is a node on the path.

Page 13: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Heuristic Evaluation Functions: Exercise

S

A

B

D

E

CH

F

G

Travel Direction

S

A S

B

S

S C

YOU

FRIEND

E(nY,n) = OddPath(nY, n, G) - EvenPath(nY, n, G)

nY is the current node on YOU turn, n is a node on the path.

Page 14: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Heuristic Evaluation Functions: Exercise

S

A S

B

S

3 paths with length:4 (S-A-D-H-G)5 (S-A-C-D-H-G)6 (S-A-C-E-F-H-G)E(S,A,G) = 1-2 = -1

3 paths with length:5 (S-B-C-D-H-G)6 (S-B-C-E-F-H-G)5 (S-B-E-F-H-G)E(S,B,G) = 2-1 = 1

S C

2 paths with length:4 (S-C-D-H-G)5 (S-C-E-F-H-G)E(S,C,G) = 1-1 = 0

YOU

S

A

B

D

E

CH

F

G

Travel Direction

E(nY,n) = OddPath(nY, n, G) - EvenPath(nY, n, G)

nY is the current node on YOU turn, n is a node on the path.

Page 15: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Heuristic Evaluation Functions: Exercise

S

A S

B

S

3 paths with length:4 (S-A-D-H-G)5 (S-A-C-D-H-G)6 (S-A-C-E-F-H-G)E(S,A,G) = 1-2 = -1

3 paths with length:5 (S-B-C-D-H-G)6 (S-B-C-E-F-H-G)5 (S-B-E-F-H-G)E(S,B,G) = 2-1 = 1

S C

2 paths with length:4 (S-C-D-H-G)5 (S-C-E-F-H-G)E(S,C,G) = 1-1 = 0

YOU picks B

YOU

S

A

B

D

E

CH

F

G

Travel Direction

E(nY,n) = OddPath(nY, n, G) - EvenPath(nY, n, G)

nY is the current node on YOU turn, n is a node on the path.

Page 16: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Alpha-Beta Pruning: Exercise

If A = 0, can leaf nodes B and C be pruned by alpha-beta pruning?

If A = 10, can leaf nodes B and C be pruned by alpha-beta pruning?

F

D E

8 A B C6

MAX

MIN

Page 17: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Alpha-Beta Pruning: Exercise

If A = 0, can leaf nodes B and C be pruned by alpha-beta pruning? Yes

If A = 10, can leaf nodes B and C be pruned by alpha-beta pruning? No

F

D E

8 A B C6

MAX

MIN

Page 18: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Alpha-Beta Pruning: Exercise

Find the interval of A such that B and C will be pruned by alpha-beta pruning.

F

D E

8 A B C6

MAX

MIN

Page 19: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Alpha-Beta Pruning: Exercise

Find the interval of A such that B and C will be pruned by alpha-beta pruning.

α = 6β = ∞

F

6 E

8 A B C6

MAX

MIN

Page 20: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Alpha-Beta Pruning: Exercise

Find the interval of A such that B and C will be pruned by alpha-beta pruning.

α = 6β = ∞

Child inherits current α β Values.

F

6 E

8 A B C6

MAX

MIN

Page 21: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Alpha-Beta Pruning: Exercise

Find the interval of A such that B and C will be pruned by alpha-beta pruning.

MIN update β Value. F

6 E

8 A B C6

MAX

MIN

α = 6β = A

Page 22: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Alpha-Beta Pruning: Exercise

Find the interval of A such that B and C will be pruned by alpha-beta pruning.

Prune if α ≥ β. 6 ≥ A A ≤ 6F

6 E

8 A B C6

MAX

MIN

α = 6β = A

Q: Does the pruning criterion (α ≥ β) hold for both MIN or MAX node?Answer is yes. α is the highest value for maximizer (MAX), and β is the lowest value for minimizer (MIN). At any node, if the highest value for maximizer is greater than or equal to the lowest value of the minimizer, then we don’t need to consider the rest of the values of its children.

Page 23: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Map Coloring: Exercise

Which map would require 4 colors to color?

(A) (B) (C) (D)

Page 24: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Map Coloring: Exercise

Which map would require 4 colors to color?

(A) (B) (C) (D)

Page 25: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Map Coloring: Exercise

Which map would require 4 colors to color?

(A) (B) (C) (D)

Page 26: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

Page 27: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

Page 28: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

Page 29: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

Page 30: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

Page 31: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

BC, NT

Page 32: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

Page 33: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

SA, NT

Page 34: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

Page 35: Games Search Constraint Satisfactionrickl/courses/cs-171/0-ihler-2016... · Game Search: Exercise 1 In the game tree below it is MAX's turn to move. At each leaf node is the estimated

Constraint Satisfaction: Exercise (Final, Fall 2014, Problem 8)

G