domains
j1=integer
j2=integer
predicates
water(j1,j2)
water(integer,integer,integer,integer)
clauses
water(2,B,_,_):-B<4.
water(A,_):-A>4,write("Jug One capacity exceeded").
water(_,B):-B>3,write("Jug two capacity exceeded").
water(A,B):-A=4,B=0,X=1,Y=3,write("jug1=",X," ","jug2=",Y).
water(P,Q):-P=1,Q=3,P1=1,Q1=0,write("jug1=",P1," ","jug2=",Q1).
water(P,Q):-P=1,Q=0,P1=0,Q1=1,write("jug1=",P1," ","jug2=",Q1).
water(P,Q):-P=0,Q=1,P1=4,Q1=1,write("jug1=",P1," ","jug2=",Q1).
water(P,Q):-P=4,Q=1,P1=2,Q1=3,write("jug1=",P1," ","jug2=",Q1),write("Solution reached").
Labels
- BFS (1)
- BNM (1)
- crypt arithmetic puzzle (1)
- depth first search (1)
- monkey banana problem (1)
- n-queen Problem (1)
- Tower of hanoi (1)
- water jug problem (1)
Friday, July 6, 2007
Subscribe to:
Post Comments (Atom)
6 comments:
nice work
just asking, what is the predicate to be checked?
@jimmy: abe chutiya nahi banaya.
go to the goal window and run the program using:
Goal: water(4,0)
The output for this query is the next input as water(-,-)
Error illegal number of parameter
Which prolog did you use?
swi or turbo or gnu.???
Post a Comment