Cs 361 2015 lec 1-2
-
Upload
alaa-zaghloul -
Category
Education
-
view
123 -
download
1
Transcript of Cs 361 2015 lec 1-2
![Page 1: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/1.jpg)
CS 361
Lac 1-2
![Page 2: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/2.jpg)
Artificial Intelligence (AI)
![Page 3: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/3.jpg)
WHAT IS AI?
AI is the study of how to make
computers make things which at the
moment people do better.
![Page 4: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/4.jpg)
DEFINING THE PROBLEM
Defining the problem as State Space
Search
Initial state
Goal state
Rules: Matching ----- forward ----> Action
![Page 5: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/5.jpg)
EXAMPLE (1): WATER JUG PROBLEM
If you have 2 jugs (4 gallon - 3 gallon), how can you get exactly 2 gallons into the 4 gallon jug?
The state space for this problem can be described as the set of ordered pairs of integers (x,y) such that x = 0, 1,2, 3 or 4 and y = 0,1,2 or 3; x represents the number of gallons of water in the 4-gallon jug and y represents the quantity of water in 3-gallon jug
The start state is (0,0) The goal state is (2,n)
![Page 6: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/6.jpg)
PRODUCTION RULES FOR WATER JUG PROBLEM
No
Current state Next State
Description
1 (x,y) if x < 4 (4,y) Fill the 4 gallon jug
2 (x,y) if y <3 (x,3) Fill the 3 gallon jug
3 (x,y) if x > 0 (x-d, y) Pour some water out of the 4 gallon jug
4 (x,y) if y > 0 (x, y-d) Pour some water out of the 3-gallon jug
5 (x,y) if x>0 (0, y) Empty the 4 gallon jug
6 (x,y) if y >0 (x,0) Empty the 3 gallon jug on the ground
7 (x,y) if x+y >= 4 and y >0
(4, y-(4-x)) Pour water from the 3 –gallon jug into the 4 –gallon jug until the 4-gallon jug is full
8 (x, y) if x+y >= 3 and x>0
(x-(3-y), 3) Pour water from the 4-gallon jug into the 3-gallon jug until the 3-gallon jug is full
9 (x, y) if x+y <=4 and y>0
(x+y, 0) Pour all the water from the 3-gallon jug into the 4-gallon jug
10 (x, y) if x+y <= 3 and x>0
(0, x+y) Pour all the water from the 4-gallon jug into the 3-gallon jug
![Page 7: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/7.jpg)
TO SOLVE THE WATER JUG PROBLEM
Gallons in the 4-gallon jug
Gallons in the 3-gallon jug Rule applied
0 0 2
0 3 9
3 0 2
3 3 7
4 2 5
0 2 9
2 0
![Page 8: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/8.jpg)
THE WATER JUGS PROBLEM – SEARCH TREE
0 , 0
4 3
0 , 3
4 , 0
0 , 0
3 , 0
4 , 3
1 , 3
4 , 3
0 , 0
0 , 3
4 , 0
0 , 0
4 , 0
0 , 3
3 , 3
0 , 3
4 , 3
1 , 0
3 , 0
4 , 2
4 , 3
0 , 3
0 , 1
4 , 0
0 , 0
1 , 3
4 , 0
3 , 3
4 , 3
0 , 2
0 , 0
0 , 3
4 , 1
1 , 0
0 , 3
4 , 2
0 , 0
2 , 0
2 , 3
0 , 1
4 , 3
4 , 0
![Page 9: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/9.jpg)
PROBLEM SEARCH
Blind Search
… Blind Search – Breadth First
… Blind Search – Depth First
Heuristic Search
![Page 10: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/10.jpg)
THE WATER JUGS PROBLEM – SEARCH TREE
0 , 0
4 3
0 , 3
4 , 0
0 , 0
3 , 0
4 , 3
1 , 3
4 , 3
0 , 0
0 , 3
4 , 0
0 , 0
4 , 0
0 , 3
3 , 3
0 , 3
4 , 3
1 , 0
3 , 0
4 , 2
4 , 3
0 , 3
0 , 1
4 , 0
0 , 0
1 , 3
4 , 0
3 , 3
4 , 3
0 , 2
0 , 0
0 , 3
4 , 1
1 , 0
0 , 3
4 , 2
0 , 0
2 , 0
2 , 3
0 , 1
4 , 3
4 , 0
![Page 11: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/11.jpg)
BLIND SEARCH – BREADTH FIRST
0 , 0
4 3
0 , 3
4 , 0
3 , 0
4 , 3
1 , 3
3 , 3
1 , 0
4 , 2
0 , 1
0 , 2
4 , 1
2 , 0
![Page 12: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/12.jpg)
THE WATER JUGS PROBLEM – SEARCH TREE
0 , 0
4 3
0 , 3
4 , 0
0 , 0
3 , 0
4 , 3
1 , 3
4 , 3
0 , 0
0 , 3
4 , 0
0 , 0
4 , 0
0 , 3
3 , 3
0 , 3
4 , 3
1 , 0
3 , 0
4 , 2
4 , 3
0 , 3
0 , 1
4 , 0
0 , 0
1 , 3
4 , 0
3 , 3
4 , 3
0 , 2
0 , 0
0 , 3
4 , 1
1 , 0
0 , 3
4 , 2
0 , 0
2 , 0
2 , 3
0 , 1
4 , 3
4 , 0
![Page 13: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/13.jpg)
BLIND SEARCH – DEPTH FIRST
0 , 0
4 3
0 , 3
3 , 0
4 , 3
3 , 3
4 , 2
0 , 2
2 , 0
![Page 14: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/14.jpg)
EXAMPLE (2): WATER JUG PROBLEM
You are given three jugs, a 10-gallon one, 7-gallon one, and 3-gallon one.
Neither have any measuring markers on it.
There is a pump that can used to fill the jugs with water.
Use Breadth First and Depth First search to get exactly 5-gallons of water into 7-gallon jug.
The start state is (0,0,0) The goal state is (n,5,n)
![Page 15: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/15.jpg)
EXAMPLE (3): TRAVERSING A MAZE The wall follower, the best-known rule for
traversing mazes, is also known as either the left-hand rule or the right-hand rule.
![Page 16: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/16.jpg)
TRAVERSING A MAZE PROBLEM – SEARCH TREE
A
CB D
FE HG I
KJ
NML
![Page 17: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/17.jpg)
TRAVERSING A MAZE PROBLEM – BREADTH FIRST
A
B D
I
K
M
![Page 18: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/18.jpg)
TRAVERSING A MAZE PROBLEM – SEARCH TREE
A
CB D
FE HG I
KJ
NML
![Page 19: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/19.jpg)
TRAVERSING A MAZE PROBLEM – DEPTH FIRST
A
B D
I
K
M
![Page 20: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/20.jpg)
EXAMPLE (4): TRAVERSING A MAZE
![Page 21: Cs 361 2015 lec 1-2](https://reader038.fdocuments.us/reader038/viewer/2022110315/55cf2606bb61eba42c8b478d/html5/thumbnails/21.jpg)
END