AI 4th Problem Solving Complete
AI 4th Problem Solving Complete
Legal Moves:
Rules: • Slide
• 1s’ move right
• 2s’ move left
• Only one move at a time • Hop
• No backing up
Two – One Problem
Trials to solve the problem
1 1?22 1 1?22
1 12?2 1 ?122
1 ?212 ? 1122
1 2?12 Stuck!!!
1 221?
1 22?1
Stuck!!!
Two – One Problem
Five States
Two – One Problem
Solution Space
H H
? 1122 11 ? 22 1122 ?
S S
1?122 112 ? 2
S H H S
1212 ? 12 ? 12 ? 1212
H
H H H
12 ? 21 ? 2112 1221 ? 21 ? 12
S H S S H S
2? 121 212 ? 1
H H
221 ? 1 2? 211
S S
22 ? 11
• Informed way for problem solving
• Systematic approach (initial state, goal state,
intermediate states , dead ends, limitations,
Representation of problem
• Graph,
• Tree
• Powerful representation
• Roadmap example
Searching
• Huge component of AI.
• We check all possibilities of problem
• Tree and graph terminology
• Root node
• Ancestor
• Descendent
• Nodes represent different states
• Edges represent the operator
• Without exploring child node that node will be
open node.
• Closed node
• Directed graph
• Undirected graph
• Blocks example
• Map example
• Tree conversion
Solution to Problem Solving : Searching
H H
? 1122 11 ? 22 1122 ?
S S
Airport
1 ? 122 112 ? 2
S H H S
?1122 121 ? 2 1 ? 212 1122 ?
Q1 Q2
S S S S
1212 ? 12 ? 12 ? 1212
H H H H
12 ? 21 ? 2112 1221 ? 21 ? 12 Q4
Q3
Q5
S H S S H S
122 ? 1 ? 2121 2 ? 112 122 ? 1 2112 ? 2 ? 112
S S Hotel
2 ? 121 212 ? 1
Farmer
H H
Grain Goose 221 ? 1 2 ? 211
Grain
S S
Farmer
Fox Fox 22 ? 11
Goose
Farmer
Farmer
Fox Fox Farmer
Fox Goose
Goose Grain Goose
Grain
Grain
Farmer
Farmer
Farmer Fox Fox
Goose Fox
Goose Grain Goose
Grain
Grain
Farmer
Fox Fox
Goose
Farmer
Goose Grain
Grain
Tree and Graph Terminology
B C
D E F G H
3 3
A B C
2
4
S G
4
3 2
D E F
1 3
Tree Search
• Graph search is really tree search
3 3
A B C A D
2
B D A E
4
S
G C E E B B F
3 2 D F B F C E A C G
D E F
1 3
G C G F
G
The 8-puzzle as a production system
Production System: Knight Tour
connect(i1,i2,b1) connect(i2,i1,b1)
connect(rb1,i1,b2) connect(i1,rb1,b2)
onnect(rb1,i1,b3) onnect(i1,rb1,b3)
connect(rb1,i2,b4) connect(i2,rb1,b4)
connect(rb2,i1,b5) connect(i1,rb2,b5)
connect(rb2,i1,b6) connect(i1,rb2,b6)
connect(rb2,i2,b7) connect(i2,rb2,b7)
Institute of Computing
Block World
on(c,a).
on(b,d).
ontable(a).
ontable(d).
clear(b).
clear(c).
hand_empty.
Institute of Computing
Types of search
• Blind or uninformed search (no knowledge
about place)
• Base on guess
• Another name brute