Professional Documents
Culture Documents
CS 312: Artificial Intelligence Laboratory: A Algorithm
CS 312: Artificial Intelligence Laboratory: A Algorithm
CS 312: Artificial Intelligence Laboratory: A Algorithm
A* Algorithm:
You are given an m litre jug and an n litre jug. Both the
jugs are initially empty. The jugs don’t have markings to
jugs to measure d
litres of water where d is less than n
.
amount of water in Jug1 and Y refers to the amount of
water in Jug2.
Initial state (xi, yi) to the final state (xf, yf), where (xi, yi) is (0, 0) which indicates both Jugs are
State-space: G
iven the capacity of the two jugs are X litre and Y litre then the
possible number of states are (X+1)*(Y+1).
MOVEGEN and GOALTEST algorithm:
MOVEGEN is implemented with name MoveGen
def MoveGen(next_item):
Goal Test:
if(next_item[1].x == target or next_item[1].y == target):
a = 1
Return True
Monotonic Heuristic:
For this, we took euclidean distance as we know that euclidean satisfies monotone
property.
50 13 35 243.923 32 243.923 28
17 3 12 28.97 20 28.97 13
We observed that both the heuristic find the path with optimal cost but no. of
states explored varies significantly. The number of states explored is very less in
underestimating heuristic function than in overestimating heuristic function.
How to Run
“ python3 Water.py”