Wrap-up First Unit Motivating Logic in AI

24
Game Playing

description

Wrap-up First Unit Motivating Logic in AI. Exam #1. My general impression as I graded the exams: You understood the general idea(s) but not the specifics/details You were able to say things that made sense, but you couldn’t identify the key ideas that show that you GET IT. Exam #1. - PowerPoint PPT Presentation

Transcript of Wrap-up First Unit Motivating Logic in AI

Page 1: Wrap-up First Unit Motivating Logic in AI

Game Playing

Page 2: Wrap-up First Unit Motivating Logic in AI
Page 3: Wrap-up First Unit Motivating Logic in AI

Pruning

• Pruning is used to narrow the search down– e.g. if we find a branch where we will win no

matter what, we don’t need to search that part of the tree anymore

– And if we find a guaranteed losing line we don’t need to search that part of tree any more

Page 4: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 5: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6(?)

3-3

Max moves

Min moves

Max moves

Min moves

Page 6: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 7: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-3(?)1-1-4(?)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 8: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3(?) 1-1-2-2(?)

2-2-21-2-3(?)1-1-4(?)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 9: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(?)

1-1-1-3(?) 1-1-2-2(?)

2-2-21-2-3(?)1-1-4(?)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 10: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(-1)

1-1-1-3(?) 1-1-2-2(?)

2-2-21-2-3(?)1-1-4(?)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 11: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(-1)

1-1-1-3(-1) 1-1-2-2(?)

2-2-21-2-3(?)1-1-4(?)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 12: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(-1)

1-1-1-3(-1) 1-1-2-2(1)

2-2-21-2-3(?)1-1-4(?)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 13: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(-1)

1-1-1-3(-1) 1-1-2-2(1)

2-2-21-2-3(?)1-1-4(1)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 14: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(-1)

1-1-1-3(-1) 1-1-2-2(1)

2-2-21-2-3(1)1-1-4(1)

1-5(?) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 15: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(-1)

1-1-1-3(-1) 1-1-2-2(1)

2-2-21-2-3(1)1-1-4(1)

1-5(1) 2-4(?)

6(?)

3-3(?)

Max moves

Min moves

Max moves

Min moves

Page 16: Wrap-up First Unit Motivating Logic in AI

MiniMax

• NIM Search tree

1-1-1-1-2(-1)

1-1-1-3(-1) 1-1-2-2(1)

2-2-21-2-3(1)1-1-4(1)

1-5(1) 2-4(?)

6(1)

3-3(?)

Max moves

Min moves

Max moves

Min moves

X X

X

Page 17: Wrap-up First Unit Motivating Logic in AI

Alpha Beta Pruning

• A generalized pruning procedure– During our depth-first search we remember

• The score of the best choice so far for Max, alpha• And the best score so far for Min, beta

– If we find a point where MIN can choose a move with the utility ≤ alpha. Then we can stop search there since

• MAX will not choose a move since there are a alternative route that is better. (Where alpha was found)

Page 18: Wrap-up First Unit Motivating Logic in AI

Alpha-Beta (-) Pruning Example

≥ 3

3

3

MAX

MIN

MAX12 8

≤ 2

2 14 5

≤ 14

2

≤5 2

Page 19: Wrap-up First Unit Motivating Logic in AI

Alpha Beta Pruning

• What can it do for us?– Allows deeper searches without penalty– Allows deeper searches at same time cost

• The result is always the same as without pruning, but a lot faster

Page 20: Wrap-up First Unit Motivating Logic in AI

Do Exact Values Matter?

Page 21: Wrap-up First Unit Motivating Logic in AI

MiniMax and Heuristics

• What about more complex games?– If the search space is too large

• We could use a heuristic function to determine which nodes to expand first. (Not very useful though)

• Limit our depth and when we reach a certain depth we evaluate the current standing there

• After evaluating we use MiniMax as usual

Page 22: Wrap-up First Unit Motivating Logic in AI

MiniMax and heuristics

• Practically, rather than implement MiniMax, we implement MiniCutoff– Don’t build the whole tree. Takes lots of

memory.– Limit the depth of “look ahead”– Use a utility function rather than an evaluation

function.

Page 23: Wrap-up First Unit Motivating Logic in AI

Cutting Off Search

Page 24: Wrap-up First Unit Motivating Logic in AI

Cutting Off Search• Issues

– Quiescence• Play has “settled down”• Evaluation function unlikely to exhibit wild swings in value in near

future– Horizon effect

• “Stalling for time”• Postpones inevitable win or damaging move by opponent

• Solutions?– Quiescence search: expand non-quiescent positions further– No general solution to horizon problem at present