Midterm Review 2
Midterm Review 2
–2
September 29, 2008
+2
–3
+3
–1
–1
+1
X +5
+4
+1
1/ 18
0
X –2
X –1
X 0
–3
X +3
X +2
Start +3
node –3
+5
–5
X 0
Alpha-Beta Pruning Example
Alpha-Beta Pruning
X X –3
Midterm Review 2
(Backed-up +1
value = +1) +5
X +1
0
–5
+5
X +2
+5
X +3
Problem #3
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 2/ 18 September 29, 2008 2 / 18
Search
CW BG
BCW G
C BWG W BCG
BCG W BGW C
G BCW
BG CW
BCGW
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 3/ 18 September 29, 2008 3 / 18
Search
Problem #5
1 2 3 3 1 2
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 4/ 18 September 29, 2008 4 / 18
Search
Problem #5 (cont.)
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 5/ 18 September 29, 2008 5 / 18
Search
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 6/ 18 September 29, 2008 6 / 18
Search
123− h=4
1 2
1 1
2 1
1 2 2
2 1
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 7/ 18 September 29, 2008 7 / 18
Search
Problem #13
2 4 3 1 2 3
1 6 8 4 8
5 7 5 6 7
start goal
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 8/ 18 September 29, 2008 8 / 18
Search
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 9/ 18 September 29, 2008 9 / 18
Search
b) MU(i, j): move empty tile at (i, j) up, empty tile is now at (i − 1, j)
MD(i, j): move empty tile at (i, j) down, empty tile is now at (i + 1, j)
ML(i, j): move empty tile at (i, j) left, empty tile is now at (i, j − 1)
MR(i, j): move empty tile at (i, j) right, empty tile is now at (i, j + 1)
c) City-block/Manhattan distance: sum of the absolute i and j distances
of all tiles from their goal positions
d) MU(3, 2), MU(2, 2), ML(1, 2), MD(1, 1), MR(2, 1)
e) h is admissible since it solves an easier problem, therefore A∗ results
in an optimal path
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 10/ 18 September 29, 2008 10 / 18
Search
1 1
− 2 3 2+3=5 2 3 − 4+3=7
148 148
567 567
1
1 2 3 1+4=5
−48
567
1 1
1 2 3 0+5=5 1 2 3 2+5=7
4−8 548
567 −67
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 11/ 18 September 29, 2008 11 / 18
Search
Problem #29
1 2 3 4 4 3 1 2
start goal
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 12/ 18 September 29, 2008 12 / 18
Search
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 13/ 18 September 29, 2008 13 / 18
Search
Solution:
a) A list of 4 numbers
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 14/ 18 September 29, 2008 14 / 18
Search
1234
2 2 2 3 3
3
f=7 2 1 3 4 6 1324 8 1243 7 3214 6.5 1 4 3 2 6.5 4 2 3 1
2 2 3 3 3
3124 1342 4321 2314 1423
4+4.5=8.5 4+3=7 5+2=7 5+3=8 5+5=10
2 3 3 3
2 7 2
6 6 7 7 2
3142 1432 4312 1243 2341 2 3 3
2 2
9.5 9.5 7+0=7 13 11
3 3 3 1423
f=9 5+5=10
2314 3124 2431 4132 4132 1342 3412 2431
f=7 f=9 f=7 6+2=8 6+4.5=10.5
2143 5+2=7 5+3=8
f=8
2 3 3
2 2
2431 4321 4213 3241 4132
5+4.5=9.5 5+2=7 5+3=8 6+5=11 6+2=8
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 15/ 18 September 29, 2008 15 / 18
Search
Problem #31
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 16/ 18 September 29, 2008 16 / 18
Search
a. Backtracking search.
2 3 2 3 2 3 2 3
Q ∗ ∗ ∗ Q ∗ ∗ ∗ Q ∗ ∗ ∗ Q ∗ ∗ ∗
6 ∗ ∗ ∗ ∗ 7
7→6 ∗ ∗ ∗ 7 6 ∗ ∗ ∗
Q back 7→6 ∗
Q 7 ∗ ∗ Q 7
6 6
6 7··· 6 7
4 ∗ ∗ ∗ ∗ 5 4 ∗ ∗ ∗ ∗ 5 → 4 ∗ ∗ ∗ ∗ 5 4 ∗ Q ∗ ∗ 5
∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗
2 3 2 3 2 3 2 3
∗ Q ∗ ∗ ∗ Q ∗ ∗ ∗ Q ∗ ∗ ∗ Q ∗ ∗
6 ∗ ∗ ∗ ∗ 7
back 6 6 ∗ ∗ ∗ Q 7 6 ∗ ∗ ∗ Q 7 6 ∗ ∗ ∗ Q 7
··· 7→ 6 7→ 6 7→ 6 7
→ 4 ∗ ∗ ∗ ∗ 5 4 ∗ ∗ ∗ ∗ 5 4 Q ∗ ∗ ∗ 5 4 Q ∗ ∗ ∗ 5
∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ Q ∗
b. Forward checking.
2 3 2 3 2 3 2 3
Q x x x Q x x x Q x x x Q x x x
6 x
6 x ∗ ∗ 7
7→6 x
6 x Q x 7
7 back 6 x
6 x x Q 7
7→6 x
6 x x Q 7
7
4 x ∗ x ∗ 5 4 x x x x 5 → 4 x ∗ x x 5 4 x Q x x 5
x ∗ ∗ x x ∗ x x x x ∗ x x x x x
2 3 2 3 2 3 2 3
x Q x x x Q x x x Q x x x Q x x
back 6 x
6 x x ∗ 7
7→6 x
6 x x Q 7
7→6 x
6 x x Q 7
7→6 x
6 x x Q 7
7
→ 4 ∗ x ∗ x 5 4 ∗ x x x 5 4 Q x x x 5 4 Q x x x 5
∗ x ∗ ∗ ∗ x ∗ x x x ∗ x x x Q x
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 17/ 18 September 29, 2008 17 / 18
Search
Q0 Q0 Q0 Q0
2 32 3 2 32 3
1 ∗ ∗ 2 ∗ ∗
6 2 7 6 Q0 ∗ ∗ ∗ 7 2 7 0
∗ ∗ ∗ 7
76 Q
6 6
c3 4
6 76 7 , c4 6 7,
1 54 ∗ ∗ ∗ ∗ 5 4 1 54 ∗ ∗ ∗ ∗ 5
2 ∗ ∗ ∗ Q0 0 ∗ ∗ ∗ Q0
Q0 Q0 Q0
2 32 3 2 32 3
3 ∗ ∗ 2 ∗ ∗ ∗
6 1 7 6 Q0 ∗ ∗ ∗ 7 3 7 0
∗ ∗ ∗ 7
76 Q
6 6
c1 4
6 76 7 , c2 6 7,
1 5 4 ∗ ∗ ∗ ∗ 5 4 1 5 4 ∗ ∗ ∗ ∗ 5
1 ∗ ∗ ∗ Q0 1 ∗ Q0 ∗ Q0
Q0 Q0
2 32 3 2 32 3
0 ∗ ∗ ∗ 1 ∗ ∗ ∗
6 1 7 6 Q0 ∗ ∗ ∗ 7 7 6 7 6 Q0
3 7 ∗ ∗ ∗ 77
c3 4 , c4 6 ,
Q0 5
6 76 6
2 5 4 ∗ ∗ ∗ ∗ 5 4 0 5 4 ∗ ∗ ∗
3 ∗ Q0 ∗ Q 0 1 ∗ Q0 ∗ ∗
Dr. Zoran Duric (CS Dept., GMU) Midterm Review 2 18/ 18 September 29, 2008 18 / 18